netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: wenxu@ucloud.cn
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2 v2] iproute: lwtunnel set TUNNEL_KEY on LWTUNNEL_IP_FLAGS
Date: Thu, 20 Dec 2018 20:15:54 -0800	[thread overview]
Message-ID: <20181220201554.609843c0@xeon-e3> (raw)
In-Reply-To: <1545265047-2815-1-git-send-email-wenxu@ucloud.cn>

On Thu, 20 Dec 2018 08:17:27 +0800
wenxu@ucloud.cn wrote:

> From: wenxu <wenxu@ucloud.cn>
> 
> ip l add dev tun type gretap external
> ip r a 10.0.0.1 encap ip dst 192.168.152.171 id 1000 dev gretap
> 
> For gretap example when the command set the id but don't set the
> TUNNEL_KEY flags. There is no key field in the send packet
> 
> Signed-off-by: wenxu <wenxu@ucloud.cn>
> ---
>  include/uapi/linux/if_tunnel.h |   20 ++++++++++++++++++++
>  ip/iproute_lwtunnel.c          |   11 ++++++++++-
>  2 files changed, 30 insertions(+), 1 deletions(-)
> 
> diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h
> index ecdc766..c7f0a5e 100644
> --- a/include/uapi/linux/if_tunnel.h
> +++ b/include/uapi/linux/if_tunnel.h

Already picked up header from kernel update

> diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
> index aee18ac..c659035 100644
> --- a/ip/iproute_lwtunnel.c
> +++ b/ip/iproute_lwtunnel.c
> @@ -18,6 +18,7 @@
>  #include <string.h>
>  #include <linux/ila.h>
>  #include <linux/lwtunnel.h>
> +#include <linux/if_tunnel.h>
>  #include <linux/mpls_iptunnel.h>
>  #include <errno.h>
>  
> @@ -31,7 +32,6 @@
>  #include <linux/seg6_iptunnel.h>
>  #include <linux/seg6_hmac.h>
>  #include <linux/seg6_local.h>
> -#include <net/if.h>
>  
>  static const char *format_encap_type(int type)
>  {
> @@ -780,12 +780,14 @@ static int parse_encap_ip(struct rtattr *rta, size_t len,
>  	char **argv = *argvp;
>  	int argc = *argcp;
>  	int ret = 0;
> +	__u16 flags = 0;
>  
>  	while (argc > 0) {
>  		if (strcmp(*argv, "id") == 0) {
>  			__u64 id;
>  
>  			NEXT_ARG();
> +			flags |= TUNNEL_KEY;

How is this backwards compatible with older kernels? You are always setting
flag. The design of the kernel attribute may be broken and have to be
reverted.

Old iproute2 has to work on 4.21 and new iproute2 has to work on old kernels
(even 2.6.32).


A bigger problem is you added a way to set the option without a corresponding way
to display the current settings. You need to look for and decode the netlink
attribute. And once again the API has to work backwards and forwards.

      reply	other threads:[~2018-12-21  4:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20  0:17 [PATCH iproute2 v2] iproute: lwtunnel set TUNNEL_KEY on LWTUNNEL_IP_FLAGS wenxu
2018-12-21  4:15 ` Stephen Hemminger [this message]

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=20181220201554.609843c0@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    --cc=wenxu@ucloud.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).