]> git.baikalelectronics.ru Git - kernel.git/commit
ipv4: fix value of ->nlmsg_flags reported in RTM_NEWROUTE events
authorGuillaume Nault <g.nault@alphalink.fr>
Wed, 7 Sep 2016 15:20:46 +0000 (17:20 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Sep 2016 23:50:23 +0000 (16:50 -0700)
commit8a24481ee279370ba65f312ef5e12f7a59095b81
tree93403e7afc5f81a62647f61b9df5570bc06e71f4
parent81a0986d1046ba868d1d389ea34b28e7cddf9f70
ipv4: fix value of ->nlmsg_flags reported in RTM_NEWROUTE events

fib_table_insert() inconsistently fills the nlmsg_flags field in its
notification messages.

Since commit 2e70b1a72fce ("[RTNETLINK]: Fix sending netlink message
when replace route."), the netlink message has its nlmsg_flags set to
NLM_F_REPLACE if the route replaced a preexisting one.

Then commit 04d851f4407e ("ipv4: include NLM_F_APPEND flag in append
route notifications") started setting nlmsg_flags to NLM_F_APPEND if
the route matched a preexisting one but was appended.

In other cases (exclusive creation or prepend), nlmsg_flags is 0.

This patch sets ->nlmsg_flags in all situations, preserving the
semantic of the NLM_F_* bits:

  * NLM_F_CREATE: a new fib entry has been created for this route.
  * NLM_F_EXCL: no other fib entry existed for this route.
  * NLM_F_REPLACE: this route has overwritten a preexisting fib entry.
  * NLM_F_APPEND: the new fib entry was added after other entries for
    the same route.

As a result, the possible flag combination can now be reported
(iproute2's terminology into parentheses):

  * NLM_F_CREATE | NLM_F_EXCL: route didn't exist, exclusive creation
    ("add").
  * NLM_F_CREATE | NLM_F_APPEND: route did already exist, new route
    added after preexisting ones ("append").
  * NLM_F_CREATE: route did already exist, new route added before
    preexisting ones ("prepend").
  * NLM_F_REPLACE: route did already exist, new route replaced the
    first preexisting one ("change").

Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/fib_trie.c