struct geneve_sock *sock; /* socket used for geneve tunnel */
u8 vni[3]; /* virtual network ID for tunnel */
u8 ttl; /* TTL override */
+ u8 tos; /* TOS override */
struct sockaddr_in remote; /* IPv4 address for link partner */
struct list_head next; /* geneve's per namespace list */
};
/* TODO: port min/max limits should be configurable */
sport = udp_flow_src_port(dev_net(dev), skb, 0, 0, true);
+ tos = geneve->tos;
+ if (tos == 1)
+ tos = ip_tunnel_get_dsfield(iip, skb);
+
memset(&fl4, 0, sizeof(fl4));
+ fl4.flowi4_tos = RT_TOS(tos);
fl4.daddr = geneve->remote.sin_addr.s_addr;
rt = ip_route_output_key(geneve->net, &fl4);
if (IS_ERR(rt)) {
goto rt_tx_error;
}
- /* TODO: tos should be configurable */
-
- tos = ip_tunnel_ecn_encap(0, iip, skb);
+ tos = ip_tunnel_ecn_encap(tos, iip, skb);
ttl = geneve->ttl;
if (!ttl && IN_MULTICAST(ntohl(fl4.daddr)))
[IFLA_GENEVE_ID] = { .type = NLA_U32 },
[IFLA_GENEVE_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
[IFLA_GENEVE_TTL] = { .type = NLA_U8 },
+ [IFLA_GENEVE_TOS] = { .type = NLA_U8 },
};
static int geneve_validate(struct nlattr *tb[], struct nlattr *data[])
if (data[IFLA_GENEVE_TTL])
geneve->ttl = nla_get_u8(data[IFLA_GENEVE_TTL]);
+ if (data[IFLA_GENEVE_TOS])
+ geneve->tos = nla_get_u8(data[IFLA_GENEVE_TOS]);
+
list_add(&geneve->next, &gn->geneve_list);
hlist_add_head_rcu(&geneve->hlist, &gn->vni_list[hash]);
return nla_total_size(sizeof(__u32)) + /* IFLA_GENEVE_ID */
nla_total_size(sizeof(struct in_addr)) + /* IFLA_GENEVE_REMOTE */
nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TTL */
+ nla_total_size(sizeof(__u8)) + /* IFLA_GENEVE_TOS */
0;
}
geneve->remote.sin_addr.s_addr))
goto nla_put_failure;
- if (nla_put_u8(skb, IFLA_GENEVE_TTL, geneve->ttl))
+ if (nla_put_u8(skb, IFLA_GENEVE_TTL, geneve->ttl) ||
+ nla_put_u8(skb, IFLA_GENEVE_TOS, geneve->tos))
goto nla_put_failure;
return 0;