u8 tos; /* TOS override */
struct sockaddr_in remote; /* IPv4 address for link partner */
struct list_head next; /* geneve's per namespace list */
+ __be16 dst_port;
};
static int geneve_net_id;
/* geneve receive/decap routine */
static void geneve_rx(struct geneve_sock *gs, struct sk_buff *skb)
{
+ struct inet_sock *sk = inet_sk(gs->sock->sk);
struct genevehdr *gnvh = geneve_hdr(skb);
struct geneve_dev *dummy, *geneve = NULL;
struct geneve_net *gn;
vni_list_head = &gn->vni_list[hash];
hlist_for_each_entry_rcu(dummy, vni_list_head, hlist) {
if (!memcmp(gnvh->vni, dummy->vni, sizeof(dummy->vni)) &&
- iph->saddr == dummy->remote.sin_addr.s_addr) {
+ iph->saddr == dummy->remote.sin_addr.s_addr &&
+ sk->inet_sport == dummy->dst_port) {
geneve = dummy;
break;
}
struct geneve_net *gn = net_generic(geneve->net, geneve_net_id);
struct geneve_sock *gs;
- gs = geneve_sock_add(net, htons(GENEVE_UDP_PORT), geneve_rx, gn,
+ gs = geneve_sock_add(net, geneve->dst_port, geneve_rx, gn,
false, false);
if (IS_ERR(gs))
return PTR_ERR(gs);
/* no need to handle local destination and encap bypass...yet... */
err = geneve_xmit_skb(gs, rt, skb, fl4.saddr, fl4.daddr,
- tos, ttl, 0, sport, htons(GENEVE_UDP_PORT), 0,
+ tos, ttl, 0, sport, geneve->dst_port, 0,
geneve->vni, 0, NULL, false,
!net_eq(geneve->net, dev_net(geneve->dev)));
if (err < 0)
[IFLA_GENEVE_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
[IFLA_GENEVE_TTL] = { .type = NLA_U8 },
[IFLA_GENEVE_TOS] = { .type = NLA_U8 },
+ [IFLA_GENEVE_PORT] = { .type = NLA_U16 },
};
static int geneve_validate(struct nlattr *tb[], struct nlattr *data[])
struct hlist_head *vni_list_head;
struct sockaddr_in remote; /* IPv4 address for link partner */
__u32 vni, hash;
+ __be16 dst_port;
int err;
if (!data[IFLA_GENEVE_ID] || !data[IFLA_GENEVE_REMOTE])
if (IN_MULTICAST(ntohl(geneve->remote.sin_addr.s_addr)))
return -EINVAL;
+ if (data[IFLA_GENEVE_PORT])
+ dst_port = htons(nla_get_u16(data[IFLA_GENEVE_PORT]));
+ else
+ dst_port = htons(GENEVE_UDP_PORT);
+
remote = geneve->remote;
hash = geneve_net_vni_hash(geneve->vni);
vni_list_head = &gn->vni_list[hash];
hlist_for_each_entry_rcu(dummy, vni_list_head, hlist) {
if (!memcmp(geneve->vni, dummy->vni, sizeof(dummy->vni)) &&
- !memcmp(&remote, &dummy->remote, sizeof(dummy->remote)))
+ !memcmp(&remote, &dummy->remote, sizeof(dummy->remote)) &&
+ dst_port == dummy->dst_port) {
return -EBUSY;
+ }
}
err = register_netdevice(dev);
if (data[IFLA_GENEVE_TOS])
geneve->tos = nla_get_u8(data[IFLA_GENEVE_TOS]);
+ geneve->dst_port = dst_port;
list_add(&geneve->next, &gn->geneve_list);
hlist_add_head_rcu(&geneve->hlist, &gn->vni_list[hash]);
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 */
+ nla_total_size(sizeof(__u16)) + /* IFLA_GENEVE_PORT */
0;
}
nla_put_u8(skb, IFLA_GENEVE_TOS, geneve->tos))
goto nla_put_failure;
+ if (nla_put_u16(skb, IFLA_GENEVE_PORT, ntohs(geneve->dst_port)))
+ goto nla_put_failure;
+
return 0;
nla_put_failure: