All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>, Phil Sutter <phil@nwl.cc>,
	Hangbin Liu <liuhangbin@gmail.com>,
	Michal Kubecek <mkubecek@suse.cz>
Subject: [PATCHv2 net-next] geneve: allow to clear ttl inherit
Date: Sat, 29 Sep 2018 23:06:29 +0800	[thread overview]
Message-ID: <1538233589-13899-1-git-send-email-liuhangbin@gmail.com> (raw)
In-Reply-To: <1538096998-20937-1-git-send-email-liuhangbin@gmail.com>

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 <mkubecek@suse.cz>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 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

  parent reply	other threads:[~2018-09-29 21:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28  1:09 [PATCH net-next] geneve: fix ttl inherit type Hangbin Liu
2018-09-28 10:38 ` Phil Sutter
2018-09-28 17:59 ` David Ahern
2018-09-29  9:20   ` Hangbin Liu
2018-09-28 23:46 ` Michal Kubecek
2018-09-29  9:16   ` Hangbin Liu
2018-10-01 10:56     ` Phil Sutter
2018-09-29 15:03   ` Hangbin Liu
2018-09-29 15:06 ` Hangbin Liu [this message]
2018-10-04 20:55   ` [PATCHv2 net-next] geneve: allow to clear ttl inherit David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1538233589-13899-1-git-send-email-liuhangbin@gmail.com \
    --to=liuhangbin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=phil@nwl.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.