Skip to content

Commit e62a22f

Browse files
committed
Merge branch 'neighbour-fix-update-of-proxy-neighbour'
Sabrina Dubroca says: ==================== neighbour: fix update of proxy neighbour While re-reading some "old" patches I ran into a small change of behavior in commit dc2a27e ("neighbour: Update pneigh_entry in pneigh_create()."). The old behavior was not consistent between ->protocol and ->flags, and didn't offer a way to clear protocol, so maybe it's better to change that (7-years-old [1]) behavior. But then we should change non-proxy neighbours as well to keep neigh/pneigh consistent. [1] df9b0e3 ("neighbor: Add protocol attribute") ==================== Link: https://patch.msgid.link/cover.1772894876.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents e8f0dc0 + 68e76fc commit e62a22f

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

net/core/neighbour.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ int pneigh_create(struct neigh_table *tbl, struct net *net,
820820
update:
821821
WRITE_ONCE(n->flags, flags);
822822
n->permanent = permanent;
823-
WRITE_ONCE(n->protocol, protocol);
823+
if (protocol)
824+
WRITE_ONCE(n->protocol, protocol);
824825
out:
825826
mutex_unlock(&tbl->phash_lock);
826827
return err;

tools/testing/selftests/net/rtnetlink.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ALL_TESTS="
2828
kci_test_fdb_get
2929
kci_test_fdb_del
3030
kci_test_neigh_get
31+
kci_test_neigh_update
3132
kci_test_bridge_parent_id
3233
kci_test_address_proto
3334
kci_test_enslave_bonding
@@ -1160,6 +1161,60 @@ kci_test_neigh_get()
11601161
end_test "PASS: neigh get"
11611162
}
11621163

1164+
kci_test_neigh_update()
1165+
{
1166+
dstip=10.0.2.4
1167+
dstmac=de:ad:be:ef:13:37
1168+
local ret=0
1169+
1170+
for proxy in "" "proxy" ; do
1171+
# add a neighbour entry without any flags
1172+
run_cmd ip neigh add $proxy $dstip dev "$devdummy" lladdr $dstmac nud permanent
1173+
run_cmd_grep $dstip ip neigh show $proxy
1174+
run_cmd_grep_fail "$dstip dev $devdummy .*\(managed\|use\|router\|extern\)" ip neigh show $proxy
1175+
1176+
# set the extern_learn flag, but no other
1177+
run_cmd ip neigh change $proxy $dstip dev "$devdummy" extern_learn
1178+
run_cmd_grep "$dstip dev $devdummy .* extern_learn" ip neigh show $proxy
1179+
run_cmd_grep_fail "$dstip dev $devdummy .* \(managed\|use\|router\)" ip neigh show $proxy
1180+
1181+
# flags are reset when not provided
1182+
run_cmd ip neigh change $proxy $dstip dev "$devdummy"
1183+
run_cmd_grep $dstip ip neigh show $proxy
1184+
run_cmd_grep_fail "$dstip dev $devdummy .* extern_learn" ip neigh show $proxy
1185+
1186+
# add a protocol
1187+
run_cmd ip neigh change $proxy $dstip dev "$devdummy" protocol boot
1188+
run_cmd_grep "$dstip dev $devdummy .* proto boot" ip neigh show $proxy
1189+
1190+
# protocol is retained when not provided
1191+
run_cmd ip neigh change $proxy $dstip dev "$devdummy"
1192+
run_cmd_grep "$dstip dev $devdummy .* proto boot" ip neigh show $proxy
1193+
1194+
# change protocol
1195+
run_cmd ip neigh change $proxy $dstip dev "$devdummy" protocol static
1196+
run_cmd_grep "$dstip dev $devdummy .* proto static" ip neigh show $proxy
1197+
1198+
# also check an extended flag for non-proxy neighs
1199+
if [ "$proxy" = "" ]; then
1200+
run_cmd ip neigh change $proxy $dstip dev "$devdummy" managed
1201+
run_cmd_grep "$dstip dev $devdummy managed" ip neigh show $proxy
1202+
1203+
run_cmd ip neigh change $proxy $dstip dev "$devdummy" lladdr $dstmac
1204+
run_cmd_grep_fail "$dstip dev $devdummy managed" ip neigh show $proxy
1205+
fi
1206+
1207+
run_cmd ip neigh del $proxy $dstip dev "$devdummy"
1208+
done
1209+
1210+
if [ $ret -ne 0 ];then
1211+
end_test "FAIL: neigh update"
1212+
return 1
1213+
fi
1214+
1215+
end_test "PASS: neigh update"
1216+
}
1217+
11631218
kci_test_bridge_parent_id()
11641219
{
11651220
local ret=0

0 commit comments

Comments
 (0)