Subject: Re: [Bugme-new] [Bug 8755] New: "ip -6 route change " behaves like "ip -6 route add"

From: Simon Arlott <[email-masked]>
Date: Mon, 16 Jul 2007 19:05:21 +0100

On 16/07/07 14:01, Patrick McHardy wrote:
> Simon Arlott wrote:
>> On 15/07/07 16:07, Patrick McHardy wrote:
>>>>>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.

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.

> The code looks like it would support it properly. Please add a
> few printks to inet6_rtm_newaddr to find out what goes wrong.

Ok.

>> 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

-- 
Simon Arlott