Thursday, July 7, 2011

BSD improve IPv6

Some continuation to the previous post:

Ping from host with code using mac addresses for gw (ipv6 addr fd00::3/128):
fd00::1 (linux host)
ping6 fd00::1
PING6(56=40+8+8 bytes) fd00::3 --> fd00::1
16 bytes from fd00::1, icmp_seq=0 hlim=64 time=4.047 ms
16 bytes from fd00::1, icmp_seq=1 hlim=64 time=1.792 ms
16 bytes from fd00::1, icmp_seq=2 hlim=64 time=0.795 ms
^C
--- fd00::1 ping6 statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.795/2.211/4.047/1.360 ms

fd00::4 (freebsd host running original code)
ping6 fd00::4
PING6(56=40+8+8 bytes) fd00::3 --> fd00::4
no response

tcpdump -nei re0 output on host with original code:
10:07:21.720560 00:01:00:00:00:04 > 33:33:00:00:00:6d, ethertype IPv6 (0x86dd), length 158: fd00::4.698 > ff02::6d.698: OLSR, seq 0xd218, length 96
10:07:21.909741 00:01:00:00:00:04 > 02:21:30:ca:dd:35, ethertype IPv4 (0x0800), length 114: 10.0.0.4.22 > 10.0.0.99.36085: Flags [P.], ack 49, win 8326, options [nop,nop,TS val 1136371185 ecr 2080490], length 48
10:07:21.910094 02:21:30:ca:dd:35 > 00:01:00:00:00:04, ethertype IPv4 (0x0800), length 66: 10.0.0.99.36085 > 10.0.0.4.22: Flags [.], ack 35472, win 1002, options [nop,nop,TS val 2080648 ecr 1136371185], length 0
10:07:21.974657 00:01:00:00:00:03 > 33:33:ff:00:00:04, ethertype IPv6 (0x86dd), length 86: fd00::3 > ff02::1:ff00:4: ICMP6, neighbor solicitation, who has fd00::4, length 32
10:07:22.014421 00:01:00:00:00:04 > 33:33:ff:00:00:03, ethertype IPv6 (0x86dd), length 86: fd00::4 > ff02::1:ff00:3: ICMP6, neighbor solicitation, who has fe80::3, length 32

So the original code, doesn't know where to send the answer for the ICMP request, that's why the other host doesn't receive anything.

Also, I tested and the code using lonklocal address, but adds only a default route works the same as the one using mac addresse, but I'm nt sure if it is the best.

Wednesday, July 6, 2011

Improve olsrd on BSD: use linklocal address or not?

Olsrd before the improvements (no filtering, each node can see all others):
IPv4:

--- 20:53:00.042579 ---------------------------------------------------- LINKS

IP address       hyst         LQ       ETX
10.0.0.3         0.000  1.000/1.000    1.000
10.0.0.2         0.000  0.839/0.761    1.565
10.0.0.1         0.000  1.000/1.000    1.000

--- 20:53:03.216848 ----------------------- TWO-HOP NEIGHBORS

IP addr (2-hop)  IP addr (1-hop)  Total cost
10.0.0.3         10.0.0.1         2.000
                 10.0.0.2         3.117
10.0.0.1         10.0.0.2         3.582
                 10.0.0.3         2.000
10.0.0.2         10.0.0.3         2.128
                 10.0.0.1         2.595

netstat output:

netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
10.0.0.0/8         link#1             U           2    13258    re0
10.0.0.1/32        00:01:00:00:00:04  U           0        0    re0
10.0.0.2           10.0.0.3           UGH         0        5    re0 =>
10.0.0.2/32        00:01:00:00:00:04  U           0        0    re0
10.0.0.3           10.0.0.2           UGH         0        2    re0 =>
10.0.0.3/32        00:01:00:00:00:04  U           0        0    re0
10.0.0.4           link#1             UHS         0        0    lo0
127.0.0.1          link#4             UH          0        0    lo0

Aliases are also created and not deleted after closing olsrd.


IPv6:
--- 21:18:09.197225 ---------------------------------------------------- LINKS

IP address                               hyst         LQ       ETX
fd00::1                                  0.000  1.000/1.000    1.000
fd00::2                                  0.000  1.000/1.000    1.000
fd00::3                                  0.000  1.000/1.000    1.000

--- 21:18:09.197602 ----------------------- TWO-HOP NEIGHBORS

IP addr (2-hop)  IP addr (1-hop)  Total cost
fd00::3          fd00::2          2.000
                 fd00::1          2.000
fd00::1          fd00::3          2.000
                 fd00::2          2.000
fd00::2          fd00::3          2.000
                 fd00::1          2.000


netstat output:
Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               ::1                           UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fd00::/8                          link#1                        U           re0
fd00::1                           fe80::1%re0                   UGH         re0
fd00::2                           fe80::2%re0                   UGH         re0
fd00::3                           fe80::3%re0                   UGH         re0
fd00::4                           link#1                        UHS         lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%re0/64                     link#1                        U           re0
fe80::201:ff:fe00:4%re0           link#1                        UHS         lo0
fe80::%re1/64                     link#2                        U           re1
fe80::201:ff:fe00:d%re1           link#2                        UHS         lo0
fe80::%lo0/64                     link#4                        U           lo0
fe80::1%lo0                       link#4                        UHS         lo0
ff01:1::/32                       fe80::201:ff:fe00:4%re0       U           re0
ff01:2::/32                       fe80::201:ff:fe00:d%re1       U           re1
ff01:4::/32                       ::1                           U           lo0
ff02::/16                         ::1                           UGRS        lo0
ff02::%re0/32                     fe80::201:ff:fe00:4%re0       U           re0
ff02::%re1/32                     fe80::201:ff:fe00:d%re1       U           re1
ff02::%lo0/32                     ::1                           U           lo0


Olsrd with no aliases added:
IPv4:
netstat output:

netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
10.0.0.0/8         link#1             U           2     8707    re0
10.0.0.1/32        00:01:00:00:00:03  U           0        0    re0
10.0.0.2/32        00:01:00:00:00:03  U           0       11    re0
10.0.0.3           link#1             UHS         0        0    lo0
10.0.0.4/32        00:01:00:00:00:03  U           0        0    re0
127.0.0.1          link#4             UH          0        0    lo0

IPv6:
netstat output:

Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0 =>
default                           fe80::4%re0                   U           re0
::1                               ::1                           UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fd00::/8                          link#1                        U           re0
fd00::3                           link#1                        UHS         lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%re0/64                     link#1                        U           re0
fe80::201:ff:fe00:3%re0           link#1                        UHS         lo0
fe80::%lo0/64                     link#4                        U           lo0
fe80::1%lo0                       link#4                        UHS         lo0
ff01:1::/32                       fe80::201:ff:fe00:3%re0       U           re0
ff01:4::/32                       ::1                           U           lo0
ff02::/16                         ::1                           UGRS        lo0
ff02::%re0/32                     fe80::201:ff:fe00:3%re0       U           re0
ff02::%lo0/32                     ::1                           U           lo0


So, instead of routes, there is only one default route created, which is not deleted after closing olsrd.

Olsrd with no aliases, and MAC addresses for IPv6 gateways:
IPv4:
netstat output:
netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
10.0.0.0/8         link#1             U           2    20770    re0
10.0.0.1/32        00:01:00:00:00:03  U           0        0    re0
10.0.0.2/32        00:01:00:00:00:03  U           0        0    re0
10.0.0.3           link#1             UHS         0        0    lo0
10.0.0.4/32        00:01:00:00:00:03  U           0        0    re0
127.0.0.1          link#4             UH          0        0    lo0

IPv6:
netstat output:
Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               ::1                           UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fd00::/8                          link#1                        U           re0
fd00::1/128                       00:01:00:00:00:03             U           re0
fd00::2/128                       00:01:00:00:00:03             U           re0
fd00::3                           link#1                        UHS         lo0
fd00::4/128                       00:01:00:00:00:03             U           re0
fe80::/10                         ::1                           UGRS        lo0
fe80::%re0/64                     link#1                        U           re0
fe80::201:ff:fe00:3%re0           link#1                        UHS         lo0
fe80::%lo0/64                     link#4                        U           lo0
fe80::1%lo0                       link#4                        UHS         lo0
ff01:1::/32                       fe80::201:ff:fe00:3%re0       U           re0
ff01:4::/32                       ::1                           U           lo0
ff02::/16                         ::1                           UGRS        lo0
ff02::%re0/32                     fe80::201:ff:fe00:3%re0       U           re0
ff02::%lo0/32                     ::1                           U           lo0