Bug 1480427 - RTM_NEWROUTE for `ip route add` and `ip route replace` considers route identity differently for Ipv6 gateway
Summary: RTM_NEWROUTE for `ip route add` and `ip route replace` considers route identi...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 26
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-11 05:13 UTC by Thomas Haller
Modified: 2018-05-29 11:46 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-29 11:46:27 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Thomas Haller 2017-08-11 05:13:16 UTC
The issue seems reproducable on Fedora 26 kernel 4.11.11-300.fc26.x86_64, but not on RHEL (3.10.0-514.26.2.el7.x86_64).
 

BACKGROUND:
===========

When adding routes via RTM_NEWROUTE netlink message, nlmsg_flags like NLM_F_CREATE, NLM_F_REPLACE influence the behavior. These correspond to what iproute2 does with

  ip route add
  ip route replace
  ip route change
  ip route append
  ip route prepend

"add" and "replace" have a certain notion of duplicate routes, like

  ip route add 192.168.7.0/24 dev bond0 advmss 5
  ip route add 192.168.7.0/24 dev bond0 advmss 6
  # fails with EEXIST

which differs from what "append" and "prepend" considers equal. Note how

  ip route append 192.168.7.0/24 dev bond0 advmss 5
  ip route append 192.168.7.0/24 dev bond0 advmss 6

succeeds.


One could say, that `ip route append|prepend` treats "advmss" property as part of the idenity of a route, while `ip route add` won't.

See also bug 1337855.


Usually, `ip route add` and `ip route replace` have the same notion of identity. That means, 
  1) If not conflicting route exists, `ip route add` would succeed and the 
     outcome would be identical to `ip route replace`.
  2) If a conflicting route exists, `ip route add` would fail with EEXIST. In 
     that case, `ip route replace` would succeed actually replacing an existing 
     route.





REPRODUCER:
===========


#!/bin/bash

IP() {
    ip netns exec IPns ip "$@"
}
IPsetup() {
    ip netns del IPns
    ip netns add IPns
    IP link add type veth
    IP link set veth0 name v
    IP link set veth1 name w
    IP link set v up
    IP link set w up
    IP addr add 192.168.9.5/25 dev v
}


# setup:
IPsetup
IP route add 2001:db8:8086::1/128 dev v
IP route add 2001:db8:abad:c0de::/64 dev v via 2001:db8:8086::1

IP route add 2001:db8:abad:c0de::/64 dev v
# fails as expected: RTNETLINK answers: File exists

IP route replace 2001:db8:abad:c0de::/64 dev v
# succeeds as expected. However:

IP -6 -d route show dev v
#unicast 2001:db8:8086::1 proto boot scope global metric 1024 pref medium
#unicast 2001:db8:abad:c0de::/64 via 2001:db8:8086::1 proto boot scope global metric 1024 pref medium
#unicast 2001:db8:abad:c0de::/64 proto boot scope global metric 1024 pref medium
#unicast fe80::/64 proto kernel scope global metric 256 pref medium
#note how the route was not replaced. Instead, the result is like `ip route prepend`.





ISSUE:
======


note how `ip route add` fails, but `ip route replace` succeeds. However, contrary to 2) above, it does not replace an existing route, instead it behaves more like `ip route prepend`.

That means, the notion of route identity in above example differs between `ip route add` and `ip route replace`.

Instead, `ip route replace` should have replaced the existing route (like `ip route add` says that there is an existing route).

Comment 1 Fedora End Of Life 2018-05-03 08:20:56 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 2 Fedora End Of Life 2018-05-29 11:46:27 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.