From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hangbin Liu Subject: [PATCH iproute2 net-next] vxlan: fix ttl inherit behavior Date: Wed, 18 Apr 2018 13:05:48 +0800 Message-ID: <1524027948-5395-1-git-send-email-liuhangbin@gmail.com> Cc: Stephen Hemminger , Jiri Benc , Hangbin Liu To: netdev@vger.kernel.org Return-path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:37043 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753244AbeDRFGA (ORCPT ); Wed, 18 Apr 2018 01:06:00 -0400 Received: by mail-pl0-f67.google.com with SMTP id f7-v6so384528plr.4 for ; Tue, 17 Apr 2018 22:06:00 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: 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 Suggested-by: Jiri Benc Signed-off-by: Hangbin Liu --- include/uapi/linux/if_link.h | 1 + ip/iplink_vxlan.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index dab5246..387f873 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -511,6 +511,7 @@ enum { IFLA_VXLAN_COLLECT_METADATA, IFLA_VXLAN_LABEL, IFLA_VXLAN_GPE, + IFLA_VXLAN_TTL_INHERIT, __IFLA_VXLAN_MAX }; #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c index 661eaa7..5804db3 100644 --- a/ip/iplink_vxlan.c +++ b/ip/iplink_vxlan.c @@ -165,14 +165,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; -- 2.5.5