Subject: Re: [PATCH 4/5] ip link ipip: Add support to configure FOU and GUE

From: Sabrina Dubroca <[email-masked]>
Date: Tue, 21 Oct 2014 18:48:24 +0200

Hello Tom,

2014-10-03, 08:55:17 -0700, Tom Herbert wrote:
> [...]
> 
> @@ -345,6 +396,44 @@ static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[
>  			       relayprefixlen);
>  		}
>  	}
> +
> +	if (tb[IFLA_IPTUN_ENCAP_TYPE] &&
> +	    *(__u16 *)RTA_DATA(tb[IFLA_IPTUN_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
> +		__u16 type = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_TYPE]);
> +		__u16 flags = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_FLAGS]);
> +		__u16 sport = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_SPORT]);
> +		__u16 dport = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_DPORT]);
> +
> +		fputs("encap ", f);
> +		switch (type) {
> +		case TUNNEL_ENCAP_FOU:
> +			fputs("fou ", f);
> +			break;
> +		case TUNNEL_ENCAP_GUE:
> +			fputs("gue ", f);
> +			break;
> +		default:
> +			fputs("unknown ", f);
> +			break;
> +		}
> +
> +		if (sport == 0)
> +			fputs("encap-sport auto ", f);
> +		else
> +			fprintf(f, "encap-sport %u", sport);
                                                ^^^
                                       missing space?

> +
> +		fprintf(f, "encap-dport %u ", dport);

You're missing a few ntohs for source/dest ports here:

./ip link add name tun1 type ipip remote 192.168.1.1 local 192.168.1.2 ttl 225 encap gue encap-sport auto encap-dport 9999 encap-csum
./ip -d link show dev tun1
7: tun1@NONE: <POINTOPOINT,NOARP> mtu 1468 qdisc noop state DOWN mode DEFAULT group default 
    link/ipip 192.168.1.2 peer 192.168.1.1 promiscuity 0 
    ipip remote 192.168.1.1 local 192.168.1.2 ttl 225 pmtudisc encap gue encap-sport auto encap-dport 3879 encap-csum noencap-csum6 
                                                                                                      ^^^^

Same comments for the next patch.

-- 
Sabrina