]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip fou: respect preferred_family for IPv6
authorSorah Fukumori <her@sorah.jp>
Thu, 25 Jun 2020 21:07:12 +0000 (06:07 +0900)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 6 Jul 2020 18:03:09 +0000 (11:03 -0700)
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>
ip/ipfou.c

index ea126b08aa6bab2de37b277f28089d89ffb137e0..9c6977705c996f80cfa97fb3719a925367ed4504 100644 (file)
 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();