From 9f5cb2348fdde71b22ad34c294433c4a193b208f Mon Sep 17 00:00:00 2001 From: Rahul Thakur Date: Wed, 8 May 2024 10:26:15 +0530 Subject: [PATCH] system-linux: inherit tos value in outer ip6 header In case of ipip6 tunnels, inherit the tos value in the ip6 header from the inner ip4 header as the default behaviour. Without this commit, the tos value in the ip6 header is hard coded to 0 which is wrong. The ipip6 mode tunnels lack a tos uci option allowing the choice of either inheriting tos value or setting it as per uci config. I will push a change to address this separately, but, in the absense of such a config, the default behaviour should be inherit the tos value from the inner ip4 header and not to hard code it to 0. This commit fixes that. Signed-off-by: Rahul Thakur --- system-linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system-linux.c b/system-linux.c index 4463a2a..016cb2c 100644 --- a/system-linux.c +++ b/system-linux.c @@ -3665,6 +3665,7 @@ static int system_add_ip6_tunnel(const char *name, const unsigned int link, struct ifinfomsg ifi = { .ifi_family = AF_UNSPEC }; struct blob_attr *cur; int ret = 0, ttl = 0; + uint32_t tun_flags = IP6_TNL_F_IGN_ENCAP_LIMIT; if (!nlm) return -1; @@ -3716,7 +3717,6 @@ static int system_add_ip6_tunnel(const char *name, const unsigned int link, if ((cur = tb[TUNNEL_ATTR_DATA])) { struct blob_attr *tb_data[__IPIP6_DATA_ATTR_MAX]; - uint32_t tun_flags = IP6_TNL_F_IGN_ENCAP_LIMIT; blobmsg_parse(ipip6_data_attr_list.params, __IPIP6_DATA_ATTR_MAX, tb_data, blobmsg_data(cur), blobmsg_len(cur)); @@ -3805,10 +3805,10 @@ static int system_add_ip6_tunnel(const char *name, const unsigned int link, nla_nest_end(nlm, fmrs); } #endif - if (tun_flags) - nla_put_u32(nlm, IFLA_IPTUN_FLAGS, tun_flags); } + nla_put_u32(nlm, IFLA_IPTUN_FLAGS, tun_flags | IP6_TNL_F_USE_ORIG_TCLASS); + nla_nest_end(nlm, infodata); nla_nest_end(nlm, linkinfo);