Skip to content

Commit

Permalink
(to squash) allow RA prefix info (multiple prefixes)
Browse files Browse the repository at this point in the history
This commit adds prefix info option to RA (multiple prefixes)
Also adds a property to allow user to disable "Router Info" option
in RA.
  • Loading branch information
abtink committed Oct 17, 2019
1 parent 3aea8bd commit e9e99bf
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 34 deletions.
175 changes: 174 additions & 1 deletion doc/router-advert-feature-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

The `"Router Advertisement"` feature enables `wpantund` to emit periodic Neighbor Discovery ICMPv6 Router Advertisement (RA) messages announcing routes on other network interfaces related to Thread network routes.

The routes included in RA message mirror all the routes added on the host primary interface corresponding to the Thread network:
The emitted RA can inlcude a set of prefixes (determined by user) or annoucne a default route.

When "Route Info" option is enabled, the routes included in RA message mirror all the routes added on the host primary interface corresponding to the Thread network:
- Host routes associated with off-mesh routes within the Thread network (when `Daemon:OffMeshRoute:AutoAddOnInterface` feature is enabled).
- Host routes associated with on-mesh prefixes within the Thread network (when `Daemon:OnMeshPrefix:AutoAddAsInterfaceRoute` feature is enabled).
- The list of interface routes is available form wpan property `IPv6:Routes`.
Expand All @@ -14,6 +16,16 @@ The wpantund RA feature can be enabled through property `RouterAdvert:Enable` (b
- `RouterAdvert:TxPeriod` the tx period of RA messages in units of seconds. Minimum period is 4 seconds, max period is 1800 seconds. The period is set to min or max if the value being set is out of the supported range. On start it is set to 10 seconds.
- `RouterAdvert:DefaultRoute:Lifetime` specifies the lifetime value in RA header (non-zero indicates that we are a default route). By default it is set to zero (i.e. not a default route).
- `RouterAdvert:DefaultRoute:Preference` specifies the default route preference. Positive value indicates high, zero indicates medium, and negative indicates low preference. Default value is zero (medium).
- `RouterAdvert:AddRouteInfoOption` can be used to enable or disable adding of "Route Info" option in RA. When set to false, the emitted RAs would not contain any "Route Info" options. By default it is enabled (set to true).
- `RouterAdvert:Prefixes` specifies the list of prefixes which are included in the RA message. This is a list-based property (we can set the entire list or use `add` or `remove` command to update the list item by item). When adding to the list, we can specify the length, valid and preferred lifetime, and associated flags (on-link and auto-config). A set of wpan properties are defined to help specify these. The value specified through these properties would apply to any next prefix added/removed to the list:

- `RouterAdvert:Prefix:PrefixLength` in bits 0-128 - default is 64.
- `RouterAdvert:Prefix:ValidLifetime` in seconds - default is 3600.
- `RouterAdvert:Prefix:PreferredLifetime` in seconds - default is 3600.
- `RouterAdvert:Prefix:Flag:OnLink` boolean value for on-link flag - default is true.
- `RouterAdvert:Prefix:Flag:AutoConfig` boolean value for auto-config flag - default is true.

When issuing a wpantund `leave` command, the list of prefixes and netifs for router advertisement will be cleared.

# Example of behavior

Expand Down Expand Up @@ -166,5 +178,166 @@ The property `RouterAdvert:DefaultRoute:Preference` determines default route pre
11:13:08.078489 IP6 (flowlabel 0xba663, hlim 255, next-header ICMPv6 (58) payload length: 56) fe80::4801:7e22:7895:a656 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 56
hop limit 255, Flags [none], pref low, router lifetime 1000s, reachable time 3600s, retrans time 0s


The command below show an example of how to add a prefix to RA.

wpanctl:wpan1> get RouterAdvert:Prefixes
RouterAdvert:Prefixes = []

We first set all related parameters using `RouterAdvert:Prefix:<Name>` properties:

wpanctl:wpan1> set RouterAdvert:Prefix:ValidLifetime 3000
wpanctl:wpan1> set RouterAdvert:Prefix:PreferredLifetime 5000
wpanctl:wpan1> set RouterAdvert:Prefix:PrefixLength 64
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:OnLink false
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:AutoConfig false
wpanctl:wpan1> add RouterAdvert:Prefixes fd00:7777::
wpanctl:wpan1>
wpanctl:wpan1> get RouterAdvert:Prefixes
RouterAdvert:Prefixes = [
"prefix: fd00:7777::/64, flags:[ ], valid lifetime:3000, preferred lifetime:5000"
]

tcpdump shows the prefix option:

20:57:26.624969 IP6 (flowlabel 0x034c9, hlim 255, next-header ICMPv6 (58) payload length: 56) fe80::70c8:17e:f25a:6733 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 56
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
source link-address option (1), length 8 (1): 00:00:00:00:00:00
0x0000: 0000 0000 0000
prefix info option (3), length 32 (4): fd00:7777::/64, Flags [none], valid time 3000s, pref. time 5000s
0x0000: 4000 0000 0bb8 0000 1388 0000 0000 fd00
0x0010: 7777 0000 0000 0000 0000 0000 0000
0x0000: 6000 34c9 0038 3aff fe80 0000 0000 0000 `.4..8:.........
0x0010: 70c8 017e f25a 6733 ff02 0000 0000 0000 p..~.Zg3........
0x0020: 0000 0000 0000 0001 8600 cb64 ff00 0000 ...........d....
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
0x0040: 0304 4000 0000 0bb8 0000 1388 0000 0000 ..@.............
0x0050: fd00 7777 0000 0000 0000 0000 0000 0000 ..ww............

Adding a new prefix with a different set of parameters:

wpanctl:wpan1> set RouterAdvert:Prefix:Flag:AutoConfig true
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:OnLink true
wpanctl:wpan1> set RouterAdvert:Prefix:PreferredLifetime 2500
wpanctl:wpan1> set RouterAdvert:Prefix:PreferredLifetime 3000
wpanctl:wpan1> set RouterAdvert:Prefix:PrefixLength 48
wpanctl:wpan1> add RouterAdvert:Prefixes fd00:4321::

wpanctl:wpan1> get RouterAdvert:Prefixes
RouterAdvert:Prefixes = [
"prefix: fd00:7777::/64, flags:[ ], valid lifetime:3000, preferred lifetime:5000"
"prefix: fd00:4321::/48, flags:[ on-link auto ], valid lifetime:3000, preferred lifetime:3000"
]

tcpdump

20:59:56.041669 IP6 (flowlabel 0x034c9, hlim 255, next-header ICMPv6 (58) payload length: 88) fe80::70c8:17e:f25a:6733 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 88
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
source link-address option (1), length 8 (1): 00:00:00:00:00:00
0x0000: 0000 0000 0000
prefix info option (3), length 32 (4): fd00:7777::/64, Flags [none], valid time 3000s, pref. time 5000s
0x0000: 4000 0000 0bb8 0000 1388 0000 0000 fd00
0x0010: 7777 0000 0000 0000 0000 0000 0000
prefix info option (3), length 32 (4): fd00:4321::/48, Flags [onlink, auto], valid time 3000s, pref. time 3000s
0x0000: 30c0 0000 0bb8 0000 0bb8 0000 0000 fd00
0x0010: 4321 0000 0000 0000 0000 0000 0000
0x0000: 6000 34c9 0058 3aff fe80 0000 0000 0000 `.4..X:.........
0x0010: 70c8 017e f25a 6733 ff02 0000 0000 0000 p..~.Zg3........
0x0020: 0000 0000 0000 0001 8600 3fee ff00 0000 ..........?.....
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
0x0040: 0304 4000 0000 0bb8 0000 1388 0000 0000 ..@.............
0x0050: fd00 7777 0000 0000 0000 0000 0000 0000 ..ww............
0x0060: 0304 30c0 0000 0bb8 0000 0bb8 0000 0000 ..0.............
0x0070: fd00 4321 0000 0000 0000 0000 0000 0000 ..C!............

Removing a prefix (when removing prefix only prefix length paramter is required along with the pregfix itself)

wpanctl:wpan1> set RouterAdvert:Prefix:PrefixLength 48
wpanctl:wpan1> remove RouterAdvert:Prefixes fd00:4321::
wpanctl:wpan1> get RouterAdvert:Prefixes
RouterAdvert:Prefixes = [
"prefix: fd00:7777::/64, flags:[ ], valid lifetime:3000, preferred lifetime:5000"
]

tcpdump

21:25:43.421691 IP6 (flowlabel 0x034c9, hlim 255, next-header ICMPv6 (58) payload length: 56) fe80::70c8:17e:f25a:6733 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 56
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
source link-address option (1), length 8 (1): 00:00:00:00:00:00
0x0000: 0000 0000 0000
prefix info option (3), length 32 (4): fd00:7777::/64, Flags [none], valid time 3000s, pref. time 5000s
0x0000: 4000 0000 0bb8 0000 1388 0000 0000 fd00
0x0010: 7777 0000 0000 0000 0000 0000 0000
0x0000: 6000 34c9 0038 3aff fe80 0000 0000 0000 `.4..8:.........
0x0010: 70c8 017e f25a 6733 ff02 0000 0000 0000 p..~.Zg3........
0x0020: 0000 0000 0000 0001 8600 cb64 ff00 0000 ...........d....
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
0x0040: 0304 4000 0000 0bb8 0000 1388 0000 0000 ..@.............
0x0050: fd00 7777 0000 0000 0000 0000 0000 0000 ..ww............

The `RouterAdvert:AddRouteInfoOption` can be used to disable adding of ant "Route Info" option to RA:

# Add a prefix to RA and also a Thread on-mesh prefix (which will add a corresponding route on host):
wpanctl:wpan1> set RouterAdvert:Netifs wpan1
wpanctl:wpan1> set RouterAdvert:Prefixes fd00:cafe:beef::
wpanctl:wpan1> get RouterAdvert:Prefixes
RouterAdvert:Prefixes = [
"prefix: fd00:cafe:beef::/64, flags:[ on-link auto ], valid lifetime:3600, preferred lifetime:3600"
]
wpanctl:wpan1> add-prefix fd00:abba:: -o -c
Successfully added prefix "fd00:abba::" len:64 stable:0 [on-mesh:1 def-route:0 config:1 dhcp:0 slaac:0 pref:0 prio:med]

wpanctl:wpan1> get IPv6:Routes
IPv6:Routes = [
"fd00:abba::/64 metric:256 "
]

wpanctl:wpan1> set RouterAdvert:Enable true

tcpdump shows prefix info and two route option.

(NOTE: Since we are seing RA with `fd00:cafe:beef::` on wpan1 interface with on-link and auto-config flags, linux itself added an address with this prefix on `wpan1` interface which in turn was pushed to NCP by wpantund and its prefix added to list of on-mesh prefixes within Thread network. This in turn caused it to be added as a router info option as well)


21:33:00.653646 IP6 (flowlabel 0x3d2ab, hlim 255, next-header ICMPv6 (58) payload length: 88) fe80::a4ab:2dcb:6a20:ca2b > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 88
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
source link-address option (1), length 8 (1): 00:00:00:00:00:00
0x0000: 0000 0000 0000
prefix info option (3), length 32 (4): fd00:cafe:beef::/64, Flags [onlink, auto], valid time 3600s, pref. time 3600s
0x0000: 40c0 0000 0e10 0000 0e10 0000 0000 fd00
0x0010: cafe beef 0000 0000 0000 0000 0000
route info option (24), length 16 (2): fd00:abba::/64, pref=medium, lifetime=3600s
0x0000: 4000 0000 0e10 fd00 abba 0000 0000
route info option (24), length 16 (2): fd00:cafe:beef::/64, pref=medium, lifetime=3600s
0x0000: 4000 0000 0e10 fd00 cafe beef 0000
0x0000: 6003 d2ab 0058 3aff fe80 0000 0000 0000 `....X:.........
0x0010: a4ab 2dcb 6a20 ca2b ff02 0000 0000 0000 ..-.j..+........
0x0020: 0000 0000 0000 0001 8600 846f ff00 0000 ...........o....
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
0x0040: 0304 40c0 0000 0e10 0000 0e10 0000 0000 ..@.............
0x0050: fd00 cafe beef 0000 0000 0000 0000 0000 ................
0x0060: 1802 4000 0000 0e10 fd00 abba 0000 0000 ..@.............
0x0070: 1802 4000 0000 0e10 fd00 cafe beef 0000 ..@.............

Now setting `RouterAdvert:AddRouteInfoOption` to `false` removes all route info options:

set RouterAdvert:AddRouteInfoOption false


21:33:43.462431 IP6 (flowlabel 0x3d2ab, hlim 255, next-header ICMPv6 (58) payload length: 56) fe80::a4ab:2dcb:6a20:ca2b > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 56
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
source link-address option (1), length 8 (1): 00:00:00:00:00:00
0x0000: 0000 0000 0000
prefix info option (3), length 32 (4): fd00:cafe:beef::/64, Flags [onlink, auto], valid time 3600s, pref. time 3600s
0x0000: 40c0 0000 0e10 0000 0e10 0000 0000 fd00
0x0010: cafe beef 0000 0000 0000 0000 0000
0x0000: 6003 d2ab 0038 3aff fe80 0000 0000 0000 `....8:.........
0x0010: a4ab 2dcb 6a20 ca2b ff02 0000 0000 0000 ..-.j..+........
0x0020: 0000 0000 0000 0001 8600 805f ff00 0000 ..........._....
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
0x0040: 0304 40c0 0000 0e10 0000 0e10 0000 0000 ..@.............
0x0050: fd00 cafe beef 0000 0000 0000 0000 0000 ................


Limitations:
- The current implementation does not support replying to Router Solicitation messages.
Loading

0 comments on commit e9e99bf

Please sign in to comment.