Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.

Commit e9e99bf

Browse files
committed
(to squash) allow RA prefix info (multiple prefixes)
This commit adds prefix info option to RA (multiple prefixes) Also adds a property to allow user to disable "Router Info" option in RA.
1 parent 3aea8bd commit e9e99bf

File tree

7 files changed

+535
-34
lines changed

7 files changed

+535
-34
lines changed

doc/router-advert-feature-guide.md

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
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.
44

5-
The routes included in RA message mirror all the routes added on the host primary interface corresponding to the Thread network:
5+
The emitted RA can inlcude a set of prefixes (determined by user) or annoucne a default route.
6+
7+
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:
68
- Host routes associated with off-mesh routes within the Thread network (when `Daemon:OffMeshRoute:AutoAddOnInterface` feature is enabled).
79
- Host routes associated with on-mesh prefixes within the Thread network (when `Daemon:OnMeshPrefix:AutoAddAsInterfaceRoute` feature is enabled).
810
- The list of interface routes is available form wpan property `IPv6:Routes`.
@@ -14,6 +16,16 @@ The wpantund RA feature can be enabled through property `RouterAdvert:Enable` (b
1416
- `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.
1517
- `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).
1618
- `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).
19+
- `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).
20+
- `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:
21+
22+
- `RouterAdvert:Prefix:PrefixLength` in bits 0-128 - default is 64.
23+
- `RouterAdvert:Prefix:ValidLifetime` in seconds - default is 3600.
24+
- `RouterAdvert:Prefix:PreferredLifetime` in seconds - default is 3600.
25+
- `RouterAdvert:Prefix:Flag:OnLink` boolean value for on-link flag - default is true.
26+
- `RouterAdvert:Prefix:Flag:AutoConfig` boolean value for auto-config flag - default is true.
27+
28+
When issuing a wpantund `leave` command, the list of prefixes and netifs for router advertisement will be cleared.
1729

1830
# Example of behavior
1931

@@ -166,5 +178,166 @@ The property `RouterAdvert:DefaultRoute:Preference` determines default route pre
166178
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
167179
hop limit 255, Flags [none], pref low, router lifetime 1000s, reachable time 3600s, retrans time 0s
168180

181+
182+
The command below show an example of how to add a prefix to RA.
183+
184+
wpanctl:wpan1> get RouterAdvert:Prefixes
185+
RouterAdvert:Prefixes = []
186+
187+
We first set all related parameters using `RouterAdvert:Prefix:<Name>` properties:
188+
189+
wpanctl:wpan1> set RouterAdvert:Prefix:ValidLifetime 3000
190+
wpanctl:wpan1> set RouterAdvert:Prefix:PreferredLifetime 5000
191+
wpanctl:wpan1> set RouterAdvert:Prefix:PrefixLength 64
192+
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:OnLink false
193+
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:AutoConfig false
194+
wpanctl:wpan1> add RouterAdvert:Prefixes fd00:7777::
195+
wpanctl:wpan1>
196+
wpanctl:wpan1> get RouterAdvert:Prefixes
197+
RouterAdvert:Prefixes = [
198+
"prefix: fd00:7777::/64, flags:[ ], valid lifetime:3000, preferred lifetime:5000"
199+
]
200+
201+
tcpdump shows the prefix option:
202+
203+
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
204+
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
205+
source link-address option (1), length 8 (1): 00:00:00:00:00:00
206+
0x0000: 0000 0000 0000
207+
prefix info option (3), length 32 (4): fd00:7777::/64, Flags [none], valid time 3000s, pref. time 5000s
208+
0x0000: 4000 0000 0bb8 0000 1388 0000 0000 fd00
209+
0x0010: 7777 0000 0000 0000 0000 0000 0000
210+
0x0000: 6000 34c9 0038 3aff fe80 0000 0000 0000 `.4..8:.........
211+
0x0010: 70c8 017e f25a 6733 ff02 0000 0000 0000 p..~.Zg3........
212+
0x0020: 0000 0000 0000 0001 8600 cb64 ff00 0000 ...........d....
213+
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
214+
0x0040: 0304 4000 0000 0bb8 0000 1388 0000 0000 ..@.............
215+
0x0050: fd00 7777 0000 0000 0000 0000 0000 0000 ..ww............
216+
217+
Adding a new prefix with a different set of parameters:
218+
219+
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:AutoConfig true
220+
wpanctl:wpan1> set RouterAdvert:Prefix:Flag:OnLink true
221+
wpanctl:wpan1> set RouterAdvert:Prefix:PreferredLifetime 2500
222+
wpanctl:wpan1> set RouterAdvert:Prefix:PreferredLifetime 3000
223+
wpanctl:wpan1> set RouterAdvert:Prefix:PrefixLength 48
224+
wpanctl:wpan1> add RouterAdvert:Prefixes fd00:4321::
225+
226+
wpanctl:wpan1> get RouterAdvert:Prefixes
227+
RouterAdvert:Prefixes = [
228+
"prefix: fd00:7777::/64, flags:[ ], valid lifetime:3000, preferred lifetime:5000"
229+
"prefix: fd00:4321::/48, flags:[ on-link auto ], valid lifetime:3000, preferred lifetime:3000"
230+
]
231+
232+
tcpdump
233+
234+
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
235+
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
236+
source link-address option (1), length 8 (1): 00:00:00:00:00:00
237+
0x0000: 0000 0000 0000
238+
prefix info option (3), length 32 (4): fd00:7777::/64, Flags [none], valid time 3000s, pref. time 5000s
239+
0x0000: 4000 0000 0bb8 0000 1388 0000 0000 fd00
240+
0x0010: 7777 0000 0000 0000 0000 0000 0000
241+
prefix info option (3), length 32 (4): fd00:4321::/48, Flags [onlink, auto], valid time 3000s, pref. time 3000s
242+
0x0000: 30c0 0000 0bb8 0000 0bb8 0000 0000 fd00
243+
0x0010: 4321 0000 0000 0000 0000 0000 0000
244+
0x0000: 6000 34c9 0058 3aff fe80 0000 0000 0000 `.4..X:.........
245+
0x0010: 70c8 017e f25a 6733 ff02 0000 0000 0000 p..~.Zg3........
246+
0x0020: 0000 0000 0000 0001 8600 3fee ff00 0000 ..........?.....
247+
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
248+
0x0040: 0304 4000 0000 0bb8 0000 1388 0000 0000 ..@.............
249+
0x0050: fd00 7777 0000 0000 0000 0000 0000 0000 ..ww............
250+
0x0060: 0304 30c0 0000 0bb8 0000 0bb8 0000 0000 ..0.............
251+
0x0070: fd00 4321 0000 0000 0000 0000 0000 0000 ..C!............
252+
253+
Removing a prefix (when removing prefix only prefix length paramter is required along with the pregfix itself)
254+
255+
wpanctl:wpan1> set RouterAdvert:Prefix:PrefixLength 48
256+
wpanctl:wpan1> remove RouterAdvert:Prefixes fd00:4321::
257+
wpanctl:wpan1> get RouterAdvert:Prefixes
258+
RouterAdvert:Prefixes = [
259+
"prefix: fd00:7777::/64, flags:[ ], valid lifetime:3000, preferred lifetime:5000"
260+
]
261+
262+
tcpdump
263+
264+
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
265+
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
266+
source link-address option (1), length 8 (1): 00:00:00:00:00:00
267+
0x0000: 0000 0000 0000
268+
prefix info option (3), length 32 (4): fd00:7777::/64, Flags [none], valid time 3000s, pref. time 5000s
269+
0x0000: 4000 0000 0bb8 0000 1388 0000 0000 fd00
270+
0x0010: 7777 0000 0000 0000 0000 0000 0000
271+
0x0000: 6000 34c9 0038 3aff fe80 0000 0000 0000 `.4..8:.........
272+
0x0010: 70c8 017e f25a 6733 ff02 0000 0000 0000 p..~.Zg3........
273+
0x0020: 0000 0000 0000 0001 8600 cb64 ff00 0000 ...........d....
274+
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
275+
0x0040: 0304 4000 0000 0bb8 0000 1388 0000 0000 ..@.............
276+
0x0050: fd00 7777 0000 0000 0000 0000 0000 0000 ..ww............
277+
278+
The `RouterAdvert:AddRouteInfoOption` can be used to disable adding of ant "Route Info" option to RA:
279+
280+
# Add a prefix to RA and also a Thread on-mesh prefix (which will add a corresponding route on host):
281+
wpanctl:wpan1> set RouterAdvert:Netifs wpan1
282+
wpanctl:wpan1> set RouterAdvert:Prefixes fd00:cafe:beef::
283+
wpanctl:wpan1> get RouterAdvert:Prefixes
284+
RouterAdvert:Prefixes = [
285+
"prefix: fd00:cafe:beef::/64, flags:[ on-link auto ], valid lifetime:3600, preferred lifetime:3600"
286+
]
287+
wpanctl:wpan1> add-prefix fd00:abba:: -o -c
288+
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]
289+
290+
wpanctl:wpan1> get IPv6:Routes
291+
IPv6:Routes = [
292+
"fd00:abba::/64 metric:256 "
293+
]
294+
295+
wpanctl:wpan1> set RouterAdvert:Enable true
296+
297+
tcpdump shows prefix info and two route option.
298+
299+
(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)
300+
301+
302+
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
303+
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
304+
source link-address option (1), length 8 (1): 00:00:00:00:00:00
305+
0x0000: 0000 0000 0000
306+
prefix info option (3), length 32 (4): fd00:cafe:beef::/64, Flags [onlink, auto], valid time 3600s, pref. time 3600s
307+
0x0000: 40c0 0000 0e10 0000 0e10 0000 0000 fd00
308+
0x0010: cafe beef 0000 0000 0000 0000 0000
309+
route info option (24), length 16 (2): fd00:abba::/64, pref=medium, lifetime=3600s
310+
0x0000: 4000 0000 0e10 fd00 abba 0000 0000
311+
route info option (24), length 16 (2): fd00:cafe:beef::/64, pref=medium, lifetime=3600s
312+
0x0000: 4000 0000 0e10 fd00 cafe beef 0000
313+
0x0000: 6003 d2ab 0058 3aff fe80 0000 0000 0000 `....X:.........
314+
0x0010: a4ab 2dcb 6a20 ca2b ff02 0000 0000 0000 ..-.j..+........
315+
0x0020: 0000 0000 0000 0001 8600 846f ff00 0000 ...........o....
316+
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
317+
0x0040: 0304 40c0 0000 0e10 0000 0e10 0000 0000 ..@.............
318+
0x0050: fd00 cafe beef 0000 0000 0000 0000 0000 ................
319+
0x0060: 1802 4000 0000 0e10 fd00 abba 0000 0000 ..@.............
320+
0x0070: 1802 4000 0000 0e10 fd00 cafe beef 0000 ..@.............
321+
322+
Now setting `RouterAdvert:AddRouteInfoOption` to `false` removes all route info options:
323+
324+
set RouterAdvert:AddRouteInfoOption false
325+
326+
327+
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
328+
hop limit 255, Flags [none], pref medium, router lifetime 0s, reachable time 3600s, retrans time 0s
329+
source link-address option (1), length 8 (1): 00:00:00:00:00:00
330+
0x0000: 0000 0000 0000
331+
prefix info option (3), length 32 (4): fd00:cafe:beef::/64, Flags [onlink, auto], valid time 3600s, pref. time 3600s
332+
0x0000: 40c0 0000 0e10 0000 0e10 0000 0000 fd00
333+
0x0010: cafe beef 0000 0000 0000 0000 0000
334+
0x0000: 6003 d2ab 0038 3aff fe80 0000 0000 0000 `....8:.........
335+
0x0010: a4ab 2dcb 6a20 ca2b ff02 0000 0000 0000 ..-.j..+........
336+
0x0020: 0000 0000 0000 0001 8600 805f ff00 0000 ..........._....
337+
0x0030: 0000 0e10 0000 0000 0101 0000 0000 0000 ................
338+
0x0040: 0304 40c0 0000 0e10 0000 0e10 0000 0000 ..@.............
339+
0x0050: fd00 cafe beef 0000 0000 0000 0000 0000 ................
340+
341+
169342
Limitations:
170343
- The current implementation does not support replying to Router Solicitation messages.

0 commit comments

Comments
 (0)