New: "ip -6 route change " behaves like "ip -6 route add"
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]/
Quoted 35 lines · On Sat, 14 Jul 2007 15:21:21 -0700 (PDT) [email protected] wrote:
http://bugzilla.kernel.org/show_bug.cgi?id=8755
Summary: "ip -6 route change " behaves like "ip -6 route add"
Product: Networking
Version: 2.5
Platform: All
OS/Version: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: IPV6
AssignedTo: [email protected]
ReportedBy: [email protected]The "ip -6 route change" command behaves as though "ip -6 route add" was used. The source of iproute2 shows that "change" uses the "
NLM_F_REPLACE" netlink flag only.ip utility, iproute2-ss070313
Changing an existing route:
# ip -6 r show 2002::/16 2002::/16 dev sit0 metric 1024 expires 4482618sec mtu 1480 advmss 7140 hoplimit 4294967295 # ip -6 r change 2002::/16 dev sit0 mtu 1280 RTNETLINK answers: File existsAdding a route using "change":
# ip -6 r change 2002::/17 dev sit0 mtu 1280 # ip -6 r show 2002::/17 2002::/17 dev sit0 metric 1024 expires 21334368sec mtu 1280 advmss 1220 hoplimit 4294967295
Quoted 15 lines · Andrew Morton
Quoted 13 lines · On Sat, 14 Jul 2007 15:21:21 -0700 (PDT) [email protected] wrote:
The "ip -6 route change" command behaves as though "ip -6 route add" was used. The source of iproute2 shows that "change" uses the "
NLM_F_REPLACE" netlink flag only.ip utility, iproute2-ss070313
Changing an existing route:
# ip -6 r show 2002::/16 2002::/16 dev sit0 metric 1024 expires 4482618sec mtu 1480 advmss 7140 hoplimit 4294967295 # ip -6 r change 2002::/16 dev sit0 mtu 1280 RTNETLINK answers: File exists
Quoted 5 lines
Quoted 5 lines
Adding a route using "change":
# ip -6 r change 2002::/17 dev sit0 mtu 1280 # ip -6 r show 2002::/17 2002::/17 dev sit0 metric 1024 expires 21334368sec mtu 1280 advmss 1220 hoplimit 4294967295
There is a difference between "add" and "change". "add" will only add a new address if there isn't already one with the same identity, "change" will allow to change attributes of an existing address, like flags, lifetime, ..., or behave similar to "add" in case the address doesn't already exist.
What kind of behaviour are you expecting?
Quoted 6 lines · Patrick McHardy
Quoted 6 lines
Quoted 6 lines
Changing an existing route:
# ip -6 r show 2002::/16 2002::/16 dev sit0 metric 1024 expires 4482618sec mtu 1480 advmss 7140 hoplimit 4294967295 # ip -6 r change 2002::/16 dev sit0 mtu 1280 RTNETLINK answers: File exists
^ This is clearly a bug, since I'm trying to change an existing route and it gives an error as if it tried to add it.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Adding a route using "change":
# ip -6 r change 2002::/17 dev sit0 mtu 1280 # ip -6 r show 2002::/17 2002::/17 dev sit0 metric 1024 expires 21334368sec mtu 1280 advmss 1220 hoplimit 4294967295
^ This shouldn't be possible!
Quoted 7 lines
There is a difference between "add" and "change". "add" will only add a new address if there isn't already one with the same identity, "change" will allow to change attributes of an existing address, like flags, lifetime, ..., or behave similar to "add" in case the address doesn't already exist.
What kind of behaviour are you expecting?
That "change" would actually change not simply add. It won't let me change anything and in fact can only add instead.
Compare it to ipv4 where "change" never adds - "replace" is "change, or add". (Also, "replace" doesn't work for v6 either).
Signature · 1 line
Simon Arlott
Quoted 11 lines · Simon Arlott
Quoted 6 lines · Patrick McHardy
Quoted 6 lines
Quoted 6 lines
Changing an existing route:
# ip -6 r show 2002::/16 2002::/16 dev sit0 metric 1024 expires 4482618sec mtu 1480 advmss 7140 hoplimit 4294967295 # ip -6 r change 2002::/16 dev sit0 mtu 1280 RTNETLINK answers: File exists^ This is clearly a bug, since I'm trying to change an existing route and it gives an error as if it tried to add it.
Agreed.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Adding a route using "change":
# ip -6 r change 2002::/17 dev sit0 mtu 1280 # ip -6 r show 2002::/17 2002::/17 dev sit0 metric 1024 expires 21334368sec mtu 1280 advmss 1220 hoplimit 4294967295^ This shouldn't be possible!
That one will probably be impossible to fix since IPv6 has never checked for NLM_F_EXCL, doing to now might break things.
Quoted 11 lines
Quoted 7 lines
There is a difference between "add" and "change". "add" will only add a new address if there isn't already one with the same identity, "change" will allow to change attributes of an existing address, like flags, lifetime, ..., or behave similar to "add" in case the address doesn't already exist.
What kind of behaviour are you expecting?
That "change" would actually change not simply add. It won't let me change anything and in fact can only add instead.
The code looks like it would support it properly. Please add a few printks to inet6_rtm_newaddr to find out what goes wrong.
Quoted 2 lines
Compare it to ipv4 where "change" never adds - "replace" is "change, or add". (Also, "replace" doesn't work for v6 either).
IPv4 doesn't check any netlink flags, so I don't think that is correct.
Quoted 8 lines · Patrick McHardy
Quoted 7 lines · Simon Arlott
Quoted 5 lines · Patrick McHardy
Quoted 5 lines
Quoted 5 lines
Adding a route using "change":
# ip -6 r change 2002::/17 dev sit0 mtu 1280 # ip -6 r show 2002::/17 2002::/17 dev sit0 metric 1024 expires 21334368sec mtu 1280 advmss 1220 hoplimit 4294967295
Quoted 5 lines
Quoted 1 line
^ This shouldn't be possible!
That one will probably be impossible to fix since IPv6 has never checked for
NLM_F_EXCL, doing to now might break things.
NLM_F_EXCL isn't used:
if (matches(*argv, "add") == 0)
return iproute_modify(RTM_NEWROUTE, NLM_F_CREATE|NLM_F_EXCL,
if (matches(*argv, "change") == 0 || strcmp(*argv, "chg") == 0)
return iproute_modify(RTM_NEWROUTE, NLM_F_REPLACE, if (matches(*argv, "replace") == 0)
return iproute_modify(RTM_NEWROUTE, NLM_F_CREATE|NLM_F_REPLACE,
"test" only uses NLM_F_EXCL... I didn't even know that existed and it's not shown in help text.
Quoted 2 lines
The code looks like it would support it properly. Please add a few printks to
inet6_rtm_newaddrto find out what goes wrong.
Ok.
Quoted 5 lines
Quoted 2 lines
Compare it to ipv4 where "change" never adds - "replace" is "change, or add". (Also, "replace" doesn't work for v6 either).
IPv4 doesn't check any netlink flags, so I don't think that is correct.
It looks like it works perfectly for add, change, and replace:
# ip r add 2.0.0.0/32 dev lo # ip r change 3.0.0.0/32 dev lo RTNETLINK answers: No such file or directory # ip r replace 3.0.0.0/32 dev lo # ip r change 2.0.0.0/32 dev lo mtu 100 # ip r 3.0.0.0 dev lo scope link 2.0.0.0 dev lo scope link mtu 100
Signature · 1 line
Simon Arlott
Quoted 10 lines · Patrick McHardy
Quoted 6 lines · Simon Arlott
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Changing an existing route:
# ip -6 r show 2002::/16 2002::/16 dev sit0 metric 1024 expires 4482618sec mtu 1480 advmss 7140 hoplimit 4294967295 # ip -6 r change 2002::/16 dev sit0 mtu 1280 RTNETLINK answers: File existsThe code looks like it would support it properly. Please add a few printks to
inet6_rtm_newaddrto find out what goes wrong.
Erm. It's routing configuration that's broken not address configuration (ip doesn't even . Looking at route.c through to ip6_fib.c, it doesn't support replacing routes at all.
$ grep NLM_F_ ipv4/fib_*.c ipv4/route.c ipv6/fib6_* ipv6/ip6_fib.c ipv6/route.c
ipv4/fib_frontend.c: cfg->fc_nlflags = NLM_F_CREATE;
ipv4/fib_frontend.c: .fc_nlflags = NLM_F_CREATE | NLM_F_APPEND,
ipv4/fib_hash.c: if (cfg->fc_nlflags & NLM_F_EXCL)
ipv4/fib_hash.c: if (cfg->fc_nlflags & NLM_F_REPLACE) {
ipv4/fib_hash.c: &cfg->fc_nlinfo,
NLM_F_REPLACE);
ipv4/fib_hash.c: if (!(cfg->fc_nlflags & NLM_F_APPEND))
ipv4/fib_hash.c: if (!(cfg->fc_nlflags & NLM_F_CREATE))
ipv4/fib_hash.c: NLM_F_MULTI) <
0) {
ipv4/fib_trie.c: if (cfg->fc_nlflags & NLM_F_EXCL)
ipv4/fib_trie.c: if (cfg->fc_nlflags & NLM_F_REPLACE) {
ipv4/fib_trie.c: tb->tb_id,
&cfg->fc_nlinfo, NLM_F_REPLACE);
ipv4/fib_trie.c: if (!(cfg->fc_nlflags & NLM_F_APPEND))
ipv4/fib_trie.c: if (!(cfg->fc_nlflags & NLM_F_CREATE))
ipv4/route.c: 1, NLM_F_MULTI) <= 0) {ipv6/route.c: prefix, NLM_F_MULTI);
Signature · 1 line
Simon Arlott