ip, neigh: Add missing NTF_USE support

Currently, ip neigh does not support the NTF_USE flag. Similar to other flags
such as extern_learn, add cmdline support. The flag dump support is explicitly
missing here, since the kernel does not propagate the flag back to user space.

Usage example:

  # ./ip/ip n replace 192.168.178.30 dev enp5s0 use extern_learn
  # ./ip/ip n
  192.168.178.30 dev enp5s0 lladdr f4:8c:50:5e:71:9a extern_learn REACHABLE
  [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David Ahern <dsahern@kernel.org>
This commit is contained in:
Daniel Borkmann 2021-10-25 17:47:27 +02:00 committed by David Ahern
parent c76a3849ec
commit 040e52526c
2 changed files with 11 additions and 1 deletions

View File

@ -51,7 +51,7 @@ static void usage(void)
fprintf(stderr, fprintf(stderr,
"Usage: ip neigh { add | del | change | replace }\n" "Usage: ip neigh { add | del | change | replace }\n"
" { ADDR [ lladdr LLADDR ] [ nud STATE ] proxy ADDR }\n" " { ADDR [ lladdr LLADDR ] [ nud STATE ] proxy ADDR }\n"
" [ dev DEV ] [ router ] [ extern_learn ] [ protocol PROTO ]\n" " [ dev DEV ] [ router ] [ use ] [ extern_learn ] [ protocol PROTO ]\n"
"\n" "\n"
" ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n" " ip neigh { show | flush } [ proxy ] [ to PREFIX ] [ dev DEV ] [ nud STATE ]\n"
" [ vrf NAME ] [ nomaster ]\n" " [ vrf NAME ] [ nomaster ]\n"
@ -148,6 +148,8 @@ static int ipneigh_modify(int cmd, int flags, int argc, char **argv)
req.ndm.ndm_flags |= NTF_PROXY; req.ndm.ndm_flags |= NTF_PROXY;
} else if (strcmp(*argv, "router") == 0) { } else if (strcmp(*argv, "router") == 0) {
req.ndm.ndm_flags |= NTF_ROUTER; req.ndm.ndm_flags |= NTF_ROUTER;
} else if (strcmp(*argv, "use") == 0) {
req.ndm.ndm_flags |= NTF_USE;
} else if (matches(*argv, "extern_learn") == 0) { } else if (matches(*argv, "extern_learn") == 0) {
req.ndm.ndm_flags |= NTF_EXT_LEARNED; req.ndm.ndm_flags |= NTF_EXT_LEARNED;
} else if (strcmp(*argv, "dev") == 0) { } else if (strcmp(*argv, "dev") == 0) {

View File

@ -25,6 +25,7 @@ ip-neighbour \- neighbour/arp tables management.
.B dev .B dev
.IR DEV " ] [ " .IR DEV " ] [ "
.BR router " ] [ " .BR router " ] [ "
.BR use " ] [ "
.BR extern_learn " ]" .BR extern_learn " ]"
.ti -8 .ti -8
@ -92,6 +93,13 @@ indicates whether we are proxying for this neighbour entry
.BI router .BI router
indicates whether neighbour is a router indicates whether neighbour is a router
.TP
.BI use
this neigh entry is in "use". This option can be used to indicate to
the kernel that a controller is using this dynamic entry. If the entry
does not exist, the kernel will resolve it. If it exists, an attempt
to refresh the neighbor entry will be triggered.
.TP .TP
.BI extern_learn .BI extern_learn
this neigh entry was learned externally. This option can be used to this neigh entry was learned externally. This option can be used to