Skip to content

Commit

Permalink
Add support for the "ignore_df" flag to TUNNEL_GRE_FLAGS (#878).
Browse files Browse the repository at this point in the history
  • Loading branch information
archiecobbs committed Sep 1, 2021
1 parent 5272db9 commit 791d837
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,8 @@ __ni_compat_generate_gre(xml_node_t *ifnode, const ni_compat_netdev_t *compat)
ni_string_array_append(&flags, ni_gre_flag_bit_to_name(NI_GRE_FLAG_OSEQ));
if (gre->flags & NI_BIT(NI_GRE_FLAG_OCSUM))
ni_string_array_append(&flags, ni_gre_flag_bit_to_name(NI_GRE_FLAG_OCSUM));
if (gre->flags & NI_BIT(NI_GRE_FLAG_IGNORE_DF))
ni_string_array_append(&flags, ni_gre_flag_bit_to_name(NI_GRE_FLAG_IGNORE_DF));

if (!ni_string_empty(ni_string_join(&str, &flags, ", ")))
xml_node_new_element("flags", child, str);
Expand Down
1 change: 1 addition & 0 deletions include/wicked/tunneling.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum {
NI_GRE_FLAG_OSEQ,
NI_GRE_FLAG_ICSUM,
NI_GRE_FLAG_OCSUM,
NI_GRE_FLAG_IGNORE_DF,
};

enum {
Expand Down
2 changes: 1 addition & 1 deletion man/ifcfg-tunnel.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ on this tunnel. PMTU discovery is disabled by default. Note that a fixed TTL is
incompatible with this option: tunnelling with a fixed TTL always makes PMTU
discovery.
.TP
.B TUNNEL_GRE_FLAGS <iseq | oseq | icsum | ocsum>
.B TUNNEL_GRE_FLAGS <iseq | oseq | icsum | ocsum | ignore_df>
Permits to specify a space separated list of flags to enable sequencing and
checksums for incoming and outgoing tunneled packets.
.TP
Expand Down
4 changes: 4 additions & 0 deletions src/ifconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3867,6 +3867,7 @@ __ni_rtnl_link_put_gre(struct nl_msg *msg, const ni_netdev_t *cfg)
struct nlattr *infodata;
uint32_t *ipaddr;
uint16_t flags;
uint8_t ignore_df;

if (!cfg->gre || !(linkinfo = nla_nest_start(msg, IFLA_LINKINFO)))
goto nla_put_failure;
Expand Down Expand Up @@ -3913,6 +3914,9 @@ __ni_rtnl_link_put_gre(struct nl_msg *msg, const ni_netdev_t *cfg)
NLA_PUT_U16(msg, IFLA_GRE_OFLAGS, flags);
NLA_PUT_U32(msg, IFLA_GRE_OKEY, cfg->gre->okey.s_addr);

ignore_df = (cfg->gre->flags & NI_GRE_FLAG_IGNORE_DF) ? 1 : 0;
NLA_PUT_U8(msg, IFLA_GRE_IGNORE_DF, ignore_df);

#if 0 /* does not work up to leap kernel */
switch (cfg->gre->encap.type) {
case NI_GRE_ENCAP_TYPE_FOU:
Expand Down
12 changes: 12 additions & 0 deletions src/iflist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2509,6 +2509,7 @@ __ni_discover_gre(ni_netdev_t *dev, struct nlattr **link_info, struct nlattr **i
ni_gre_t *gre;
unsigned int iflags = 0;
unsigned int oflags = 0;
uint8_t ignore_df;

if (!(gre = ni_netdev_get_gre(dev)) ||
__ni_discover_tunnel(&gre->tunnel, NI_IFTYPE_GRE, info_data) < 0 ||
Expand Down Expand Up @@ -2550,6 +2551,12 @@ __ni_discover_gre(ni_netdev_t *dev, struct nlattr **link_info, struct nlattr **i
gre->flags |= NI_BIT(NI_GRE_FLAG_OCSUM);
}

if (info_data[IFLA_GRE_IGNORE_DF]) {
ignore_df = nla_get_u8(info_data[IFLA_GRE_IGNORE_DF]);
if (ignore_df)
gre->flags |= NI_BIT(NI_GRE_FLAG_IGNORE_DF);
}

if (info_data[IFLA_GRE_ENCAP_TYPE]) {
gre->encap.type = nla_get_u16(info_data[IFLA_GRE_ENCAP_TYPE]);
} else gre->encap.type = NI_GRE_ENCAP_TYPE_NONE;
Expand Down Expand Up @@ -2629,6 +2636,7 @@ __ni_tunnel_gre_trace(ni_netdev_t *dev, struct nlattr **info_data)
uint32_t link;
uint16_t flags;
uint8_t pmtudisc;
uint8_t ignore_df;
uint8_t tos;
uint8_t ttl;

Expand Down Expand Up @@ -2657,6 +2665,10 @@ __ni_tunnel_gre_trace(ni_netdev_t *dev, struct nlattr **info_data)
pmtudisc = nla_get_u8(info_data[IFLA_GRE_PMTUDISC]);
ni_trace("%s:IFLA_GRE_PMTUDISC: %u", dev->name, pmtudisc);
}
if (info_data[IFLA_GRE_IGNORE_DF]) {
ignore_df = nla_get_u8(info_data[IFLA_GRE_IGNORE_DF]);
ni_trace("%s:IFLA_GRE_IGNORE_DF: %u", dev->name, ignore_df);
}
if (info_data[IFLA_GRE_FLAGS]) {
flags = nla_get_u16(info_data[IFLA_GRE_FLAGS]);
ni_trace("%s:IFLA_GRE_FLAGS: %u", dev->name, flags);
Expand Down
47 changes: 46 additions & 1 deletion src/linux/if_tunnel.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _IF_TUNNEL_H_
#define _IF_TUNNEL_H_

Expand All @@ -24,9 +25,23 @@
#define GRE_SEQ __cpu_to_be16(0x1000)
#define GRE_STRICT __cpu_to_be16(0x0800)
#define GRE_REC __cpu_to_be16(0x0700)
#define GRE_FLAGS __cpu_to_be16(0x00F8)
#define GRE_ACK __cpu_to_be16(0x0080)
#define GRE_FLAGS __cpu_to_be16(0x0078)
#define GRE_VERSION __cpu_to_be16(0x0007)

#define GRE_IS_CSUM(f) ((f) & GRE_CSUM)
#define GRE_IS_ROUTING(f) ((f) & GRE_ROUTING)
#define GRE_IS_KEY(f) ((f) & GRE_KEY)
#define GRE_IS_SEQ(f) ((f) & GRE_SEQ)
#define GRE_IS_STRICT(f) ((f) & GRE_STRICT)
#define GRE_IS_REC(f) ((f) & GRE_REC)
#define GRE_IS_ACK(f) ((f) & GRE_ACK)

#define GRE_VERSION_0 __cpu_to_be16(0x0000)
#define GRE_VERSION_1 __cpu_to_be16(0x0001)
#define GRE_PROTO_PPP __cpu_to_be16(0x880b)
#define GRE_PPTP_KEY_MASK __cpu_to_be32(0xffff)

struct ip_tunnel_parm {
char name[IFNAMSIZ];
int link;
Expand Down Expand Up @@ -57,6 +72,8 @@ enum {
IFLA_IPTUN_ENCAP_FLAGS,
IFLA_IPTUN_ENCAP_SPORT,
IFLA_IPTUN_ENCAP_DPORT,
IFLA_IPTUN_COLLECT_METADATA,
IFLA_IPTUN_FWMARK,
__IFLA_IPTUN_MAX,
};
#define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
Expand All @@ -65,6 +82,7 @@ enum tunnel_encap_types {
TUNNEL_ENCAP_NONE,
TUNNEL_ENCAP_FOU,
TUNNEL_ENCAP_GUE,
TUNNEL_ENCAP_MPLS,
};

#define TUNNEL_ENCAP_FLAG_CSUM (1<<0)
Expand Down Expand Up @@ -113,6 +131,12 @@ enum {
IFLA_GRE_ENCAP_SPORT,
IFLA_GRE_ENCAP_DPORT,
IFLA_GRE_COLLECT_METADATA,
IFLA_GRE_IGNORE_DF,
IFLA_GRE_FWMARK,
IFLA_GRE_ERSPAN_INDEX,
IFLA_GRE_ERSPAN_VER,
IFLA_GRE_ERSPAN_DIR,
IFLA_GRE_ERSPAN_HWID,
__IFLA_GRE_MAX,
};

Expand All @@ -128,8 +152,29 @@ enum {
IFLA_VTI_OKEY,
IFLA_VTI_LOCAL,
IFLA_VTI_REMOTE,
IFLA_VTI_FWMARK,
__IFLA_VTI_MAX,
};

#define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1)

#define TUNNEL_CSUM __cpu_to_be16(0x01)
#define TUNNEL_ROUTING __cpu_to_be16(0x02)
#define TUNNEL_KEY __cpu_to_be16(0x04)
#define TUNNEL_SEQ __cpu_to_be16(0x08)
#define TUNNEL_STRICT __cpu_to_be16(0x10)
#define TUNNEL_REC __cpu_to_be16(0x20)
#define TUNNEL_VERSION __cpu_to_be16(0x40)
#define TUNNEL_NO_KEY __cpu_to_be16(0x80)
#define TUNNEL_DONT_FRAGMENT __cpu_to_be16(0x0100)
#define TUNNEL_OAM __cpu_to_be16(0x0200)
#define TUNNEL_CRIT_OPT __cpu_to_be16(0x0400)
#define TUNNEL_GENEVE_OPT __cpu_to_be16(0x0800)
#define TUNNEL_VXLAN_OPT __cpu_to_be16(0x1000)
#define TUNNEL_NOCACHE __cpu_to_be16(0x2000)
#define TUNNEL_ERSPAN_OPT __cpu_to_be16(0x4000)

#define TUNNEL_OPTIONS_PRESENT \
(TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)

#endif /* _IF_TUNNEL_H_ */
1 change: 1 addition & 0 deletions src/tunneling.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ static const ni_intmap_t ni_gre_flag_bit_names[] = {
{ "oseq", NI_GRE_FLAG_OSEQ },
{ "icsum", NI_GRE_FLAG_ICSUM },
{ "ocsum", NI_GRE_FLAG_OCSUM },
{ "ignore-df", NI_GRE_FLAG_IGNORE_DF },
{ NULL, 0 },
};

Expand Down

0 comments on commit 791d837

Please sign in to comment.