summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSorah Fukumori <her@sorah.jp>2020-06-26 06:07:12 +0900
committerStephen Hemminger <stephen@networkplumber.org>2020-07-06 11:03:09 -0700
commit9e5d246877ec14ea159ad1b2a495aa9475fa6502 (patch)
treee53a5a8a2663f0306155d30b5cadd4f201d850f4
parentd80a05b7954505f73434e6fb051c098c80fd4361 (diff)
ip fou: respect preferred_family for IPv6
ip(8) accepts -family ipv6 (-6) option at the toplevel. It is straightforward to support the existing option for modifying listener on IPv6 addresses. Maintain the backward compatibility by leaving ip fou -6 flag implemented, while it's removed from the usage message. Signed-off-by: Sorah Fukumori <her@sorah.jp> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r--ip/ipfou.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ip/ipfou.c b/ip/ipfou.c
index ea126b08..9c697770 100644
--- a/ip/ipfou.c
+++ b/ip/ipfou.c
@@ -27,10 +27,10 @@
static void usage(void)
{
fprintf(stderr,
- "Usage: ip fou add port PORT { ipproto PROTO | gue } [ -6 ]\n"
+ "Usage: ip fou add port PORT { ipproto PROTO | gue }\n"
" [ local IFADDR ] [ peer IFADDR ]\n"
" [ peer_port PORT ] [ dev IFNAME ]\n"
- " ip fou del port PORT [ -6 ] [ local IFADDR ]\n"
+ " ip fou del port PORT [ local IFADDR ]\n"
" [ peer IFADDR ] [ peer_port PORT ]\n"
" [ dev IFNAME ]\n"
" ip fou show\n"
@@ -55,13 +55,17 @@ static int fou_parse_opt(int argc, char **argv, struct nlmsghdr *n,
{
const char *local = NULL, *peer = NULL;
__u16 port, peer_port = 0;
- __u8 family = AF_INET;
+ __u8 family = preferred_family;
bool gue_set = false;
int ipproto_set = 0;
__u8 ipproto, type;
int port_set = 0;
int index = 0;
+ if (preferred_family == AF_UNSPEC) {
+ family = AF_INET;
+ }
+
while (argc > 0) {
if (!matches(*argv, "port")) {
NEXT_ARG();