From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hangbin Liu Subject: [PATCHv2 net-next] geneve: allow to clear ttl inherit Date: Sat, 29 Sep 2018 23:06:29 +0800 Message-ID: <1538233589-13899-1-git-send-email-liuhangbin@gmail.com> References: <1538096998-20937-1-git-send-email-liuhangbin@gmail.com> Cc: David Miller , Phil Sutter , Hangbin Liu , Michal Kubecek To: netdev@vger.kernel.org Return-path: Received: from mail-pg1-f195.google.com ([209.85.215.195]:38293 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbeI2Vfq (ORCPT ); Sat, 29 Sep 2018 17:35:46 -0400 Received: by mail-pg1-f195.google.com with SMTP id r77-v6so6507031pgr.5 for ; Sat, 29 Sep 2018 08:07:00 -0700 (PDT) In-Reply-To: <1538096998-20937-1-git-send-email-liuhangbin@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: As Michal remaind, we should allow to clear ttl inherit. Then we will have three states: 1. set the flag, and do ttl inherit. 2. do not set the flag, use configured ttl value, or default ttl (0) if not set. 3. disable ttl inherit, use previous configured ttl value, or default ttl (0). Fixes: 52d0d404d39dd ("geneve: add ttl inherit support") CC: Michal Kubecek Signed-off-by: Hangbin Liu --- drivers/net/geneve.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 6625fab..82eccc9 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -1325,11 +1325,15 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], info->key.tun_id = tunid; } - if (data[IFLA_GENEVE_TTL]) + if (data[IFLA_GENEVE_TTL_INHERIT]) { + if (nla_get_u8(data[IFLA_GENEVE_TTL_INHERIT])) + *ttl_inherit = true; + else + *ttl_inherit = false; + } else if (data[IFLA_GENEVE_TTL]) { info->key.ttl = nla_get_u8(data[IFLA_GENEVE_TTL]); - - if (data[IFLA_GENEVE_TTL_INHERIT]) - *ttl_inherit = true; + *ttl_inherit = false; + } if (data[IFLA_GENEVE_TOS]) info->key.tos = nla_get_u8(data[IFLA_GENEVE_TOS]); -- 2.5.5