]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
vxlan: fix ttl inherit behavior
authorHangbin Liu <liuhangbin@gmail.com>
Wed, 18 Apr 2018 05:05:48 +0000 (13:05 +0800)
committerDavid Ahern <dsahern@gmail.com>
Thu, 19 Apr 2018 18:11:27 +0000 (11:11 -0700)
Like kernel net-next commit 72f6d71e491e6 ("vxlan: add ttl inherit support"),
vxlan ttl inherit should means inherit the inner protocol's ttl value.

But currently when we add vxlan with "ttl inherit", we only set ttl 0,
which is actually use whatever default value instead of inherit the inner
protocol's ttl value.

To make a difference with ttl inherit and ttl == 0, we add an attribute
IFLA_VXLAN_TTL_INHERIT when "ttl inherit" specified. And use "ttl auto"
to means "use whatever default value", the same behavior with ttl == 0.

Reported-by: Jianlin Shi <jishi@redhat.com>
Suggested-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
ip/iplink_vxlan.c

index be9f35e4d9c6bc1721c5d9654a8cf56956eba175..d4d793b6574718567d9d771a1b9cc43c041c77ae 100644 (file)
@@ -143,14 +143,18 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
-                       if (strcmp(*argv, "inherit") != 0) {
+                       if (strcmp(*argv, "inherit") == 0) {
+                               addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+                       } else if (strcmp(*argv, "auto") == 0) {
+                               addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
+                       } else {
                                if (get_unsigned(&uval, *argv, 0))
                                        invarg("invalid TTL", *argv);
                                if (uval > 255)
                                        invarg("TTL must be <= 255", *argv);
                                ttl = uval;
+                               addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
                        }
-                       addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
                } else if (!matches(*argv, "tos") ||
                           !matches(*argv, "dsfield")) {
                        __u32 uval;