netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* iproute2 - modifying routes in place
@ 2018-05-11 11:42 Ryan Whelan
  2018-05-12 17:00 ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Whelan @ 2018-05-11 11:42 UTC (permalink / raw)
  To: netdev

`ip route` has 2 subcommands that don't seem to work as expected and i'm
not sure if its a bug, or if i'm misunderstanding the semantics.

I am unable to modify a route 'in place', which from what i'm reading
online, I should be able to do with `ip route change` and/or `ip route
replace`.

After a route is created with either `ip route add` or `ip route replace`,
I am unable to use `change`, regardless of how I attempt to identify the
route i'm trying to alter.

  # ip -6 route show
...
fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1000 pref medium
fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
fe80::/64 dev internal0 proto kernel metric 256 pref medium


If i try to change the metric of the route that already exist via `ip route
change`, i get "No such file or directory.

# ip -6 route change fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0
src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 100
RTNETLINK answers: No such file or directory


If i use `replace`, the command does not error, but creates another route
instead of replacing the current route.

# ip -6 route replace fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0
src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 100

# ip -6 route show
...
fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 100 pref medium
fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1000 pref medium
fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
fe80::/64 dev internal0 proto kernel metric 256 pref medium

What am I missing or doing wrong?  Forgive me if i'm being dense, but i
could not find an answer online to explain this behavior.

If this is the wrong forum for this question, I apologize; please point me
in the right direction?

Linux: 4.16.6
iproute2: 4.15.0

Thank you!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: iproute2 - modifying routes in place
  2018-05-11 11:42 iproute2 - modifying routes in place Ryan Whelan
@ 2018-05-12 17:00 ` David Ahern
  2018-05-14 18:40   ` Ryan Whelan
  0 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2018-05-12 17:00 UTC (permalink / raw)
  To: Ryan Whelan, netdev

On 5/11/18 4:42 AM, Ryan Whelan wrote:
> `ip route` has 2 subcommands that don't seem to work as expected and i'm
> not sure if its a bug, or if i'm misunderstanding the semantics.

Can you try with ipv6/route-bugs branch in
https://github.com/dsahern/linux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: iproute2 - modifying routes in place
  2018-05-12 17:00 ` David Ahern
@ 2018-05-14 18:40   ` Ryan Whelan
  2018-05-14 18:49     ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Whelan @ 2018-05-14 18:40 UTC (permalink / raw)
  To: dsahern; +Cc: netdev

Same behavior:


root@rwhelan-linux ~
# ip -6 route
::1 dev lo proto kernel metric 256 pref medium
fd9b:caee:ff93:ceef:3431:3831:3930:3031 dev internal0 proto kernel metric
256 pref medium
fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1024 pref medium
fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
fe80::/64 dev internal0 proto kernel metric 256 pref medium

root@rwhelan-linux ~
# ip -6 route change fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0
src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10
RTNETLINK answers: No such file or directory

root@rwhelan-linux ~
# ip -6 route replace fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0
src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10

root@rwhelan-linux ~
# ip -6 route
::1 dev lo proto kernel metric 256 pref medium
fd9b:caee:ff93:ceef:3431:3831:3930:3031 dev internal0 proto kernel metric
256 pref medium
fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10 pref medium
fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1024 pref medium
fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
fe80::/64 dev internal0 proto kernel metric 256 pref medium

root@rwhelan-linux ~
# uname -a
Linux rwhelan-linux 4.17.0-rc3-ipv6-route-bugs+ #2 SMP Mon May 14 11:30:38
EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
On Sat, May 12, 2018 at 1:01 PM David Ahern <dsahern@gmail.com> wrote:

> On 5/11/18 4:42 AM, Ryan Whelan wrote:
> > `ip route` has 2 subcommands that don't seem to work as expected and i'm
> > not sure if its a bug, or if i'm misunderstanding the semantics.

> Can you try with ipv6/route-bugs branch in
> https://github.com/dsahern/linux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: iproute2 - modifying routes in place
  2018-05-14 18:40   ` Ryan Whelan
@ 2018-05-14 18:49     ` David Ahern
  2018-05-14 20:10       ` Ryan Whelan
  0 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2018-05-14 18:49 UTC (permalink / raw)
  To: Ryan Whelan; +Cc: netdev

On 5/14/18 12:40 PM, Ryan Whelan wrote:
> Same behavior:
> 
> 
> root@rwhelan-linux ~
> # ip -6 route
> ::1 dev lo proto kernel metric 256 pref medium
> fd9b:caee:ff93:ceef:3431:3831:3930:3031 dev internal0 proto kernel metric
> 256 pref medium
> fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
> fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1024 pref medium
> fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
> fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
> fe80::/64 dev internal0 proto kernel metric 256 pref medium
> 
> root@rwhelan-linux ~
> # ip -6 route change fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0
> src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10
> RTNETLINK answers: No such file or directory

'change' only sets NLM_F_REPLACE. Since NLM_F_CREATE is not set ('ip ro
replace') it does not add a new route and expects one to exist. Your
table above shows the prefix with metric 256 not metric 10 so the route
does not match. You should be seeing a message in dmesg to this effect.

> 
> root@rwhelan-linux ~
> # ip -6 route replace fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0
> src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10

Adds a new entry because of NLM_F_CREATE.

> 
> root@rwhelan-linux ~
> # ip -6 route
> ::1 dev lo proto kernel metric 256 pref medium
> fd9b:caee:ff93:ceef:3431:3831:3930:3031 dev internal0 proto kernel metric
> 256 pref medium
> fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
> fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10 pref medium
> fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
> fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1024 pref medium
> fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
> fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
> fe80::/64 dev internal0 proto kernel metric 256 pref medium
> 
> root@rwhelan-linux ~
> # uname -a
> Linux rwhelan-linux 4.17.0-rc3-ipv6-route-bugs+ #2 SMP Mon May 14 11:30:38
> EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
> On Sat, May 12, 2018 at 1:01 PM David Ahern <dsahern@gmail.com> wrote:
> 
>> On 5/11/18 4:42 AM, Ryan Whelan wrote:
>>> `ip route` has 2 subcommands that don't seem to work as expected and i'm
>>> not sure if its a bug, or if i'm misunderstanding the semantics.
> 
>> Can you try with ipv6/route-bugs branch in
>> https://github.com/dsahern/linux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: iproute2 - modifying routes in place
  2018-05-14 18:49     ` David Ahern
@ 2018-05-14 20:10       ` Ryan Whelan
  2018-05-14 20:20         ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Ryan Whelan @ 2018-05-14 20:10 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev

On Mon, May 14, 2018 at 2:49 PM David Ahern <dsahern@gmail.com> wrote:

> On 5/14/18 12:40 PM, Ryan Whelan wrote:
> > Same behavior:
> >
> >
> > root@rwhelan-linux ~
> > # ip -6 route
> > ::1 dev lo proto kernel metric 256 pref medium
> > fd9b:caee:ff93:ceef:3431:3831:3930:3031 dev internal0 proto kernel
metric
> > 256 pref medium
> > fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
> > fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1024 pref medium
> > fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
> > fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
> > fe80::/64 dev internal0 proto kernel metric 256 pref medium
> >
> > root@rwhelan-linux ~
> > # ip -6 route change fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev
internal0
> > src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10
> > RTNETLINK answers: No such file or directory

> 'change' only sets NLM_F_REPLACE. Since NLM_F_CREATE is not set ('ip ro
> replace') it does not add a new route and expects one to exist. Your
> table above shows the prefix with metric 256 not metric 10 so the route
> does not match. You should be seeing a message in dmesg to this effect.


Is there a syntax for changing a route in-place?  Specifically, i'm
interesting in changing the metric of currently existing routes.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: iproute2 - modifying routes in place
  2018-05-14 20:10       ` Ryan Whelan
@ 2018-05-14 20:20         ` David Ahern
  0 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2018-05-14 20:20 UTC (permalink / raw)
  To: Ryan Whelan; +Cc: netdev

On 5/14/18 2:10 PM, Ryan Whelan wrote:
> On Mon, May 14, 2018 at 2:49 PM David Ahern <dsahern@gmail.com> wrote:
> 
>> On 5/14/18 12:40 PM, Ryan Whelan wrote:
>>> Same behavior:
>>>
>>>
>>> root@rwhelan-linux ~
>>> # ip -6 route
>>> ::1 dev lo proto kernel metric 256 pref medium
>>> fd9b:caee:ff93:ceef:3431:3831:3930:3031 dev internal0 proto kernel
> metric
>>> 256 pref medium
>>> fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev internal0 src
>>> fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 1024 pref medium
>>> fe80::/64 dev enp0s3 proto kernel metric 256 pref medium
>>> fe80::/64 dev enp0s8 proto kernel metric 256 pref medium
>>> fe80::/64 dev internal0 proto kernel metric 256 pref medium
>>>
>>> root@rwhelan-linux ~
>>> # ip -6 route change fd9b:caee:ff93:ceef:3431:3831:3930:3032 dev
> internal0
>>> src fd9b:caee:ff93:ceef:3431:3831:3930:3031 metric 10
>>> RTNETLINK answers: No such file or directory
> 
>> 'change' only sets NLM_F_REPLACE. Since NLM_F_CREATE is not set ('ip ro
>> replace') it does not add a new route and expects one to exist. Your
>> table above shows the prefix with metric 256 not metric 10 so the route
>> does not match. You should be seeing a message in dmesg to this effect.
> 
> 
> Is there a syntax for changing a route in-place?  Specifically, i'm
> interesting in changing the metric of currently existing routes.
> 

No. Metric is one of the keys. You will need to insert and delete.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-14 20:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-11 11:42 iproute2 - modifying routes in place Ryan Whelan
2018-05-12 17:00 ` David Ahern
2018-05-14 18:40   ` Ryan Whelan
2018-05-14 18:49     ` David Ahern
2018-05-14 20:10       ` Ryan Whelan
2018-05-14 20:20         ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).