Skip to content

Commit 6eba08c

Browse files
idoschdavem330
authored andcommitted
ipv6: Only emit append events for appended routes
Current code will emit an append event in the FIB notification chain for any route added with NLM_F_APPEND set, even if the route was not appended to any existing route. This is inconsistent with IPv4 where such an event is only emitted when the new route is appended after an existing one. Align IPv6 behavior with IPv4, thereby allowing listeners to more easily handle these events. Fixes: f34436a ("net/ipv6: Simplify route replace and appending into multipath route") Signed-off-by: Ido Schimmel <[email protected]> Acked-by: Jiri Pirko <[email protected]> Acked-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 41f9ba6 commit 6eba08c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

net/ipv6/ip6_fib.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
934934
{
935935
struct fib6_info *leaf = rcu_dereference_protected(fn->leaf,
936936
lockdep_is_held(&rt->fib6_table->tb6_lock));
937+
enum fib_event_type event = FIB_EVENT_ENTRY_ADD;
937938
struct fib6_info *iter = NULL, *match = NULL;
938939
struct fib6_info __rcu **ins;
939940
int replace = (info->nlh &&
@@ -1013,6 +1014,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
10131014
"Can not append to a REJECT route");
10141015
return -EINVAL;
10151016
}
1017+
event = FIB_EVENT_ENTRY_APPEND;
10161018
rt->fib6_nsiblings = match->fib6_nsiblings;
10171019
list_add_tail(&rt->fib6_siblings, &match->fib6_siblings);
10181020
match->fib6_nsiblings++;
@@ -1034,15 +1036,12 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
10341036
* insert node
10351037
*/
10361038
if (!replace) {
1037-
enum fib_event_type event;
1038-
10391039
if (!add)
10401040
pr_warn("NLM_F_CREATE should be set when creating new route\n");
10411041

10421042
add:
10431043
nlflags |= NLM_F_CREATE;
10441044

1045-
event = append ? FIB_EVENT_ENTRY_APPEND : FIB_EVENT_ENTRY_ADD;
10461045
err = call_fib6_entry_notifiers(info->nl_net, event, rt,
10471046
extack);
10481047
if (err)

0 commit comments

Comments
 (0)