Skip to content

Commit a45e92a

Browse files
Gerhard Stenzeldavem330
authored andcommitted
vxlan: fix incorrect initializer in union vxlan_addr
The first initializer in the following union vxlan_addr ipa = { .sin.sin_addr.s_addr = tip, .sa.sa_family = AF_INET, }; is optimised away by the compiler, due to the second initializer, therefore initialising .sin.sin_addr.s_addr always to 0. This results in netlink messages indicating a L3 miss never contain the missed IP address. This was observed with GCC 4.8 and 4.9. I do not know about previous versions. The problem affects user space programs relying on an IP address being sent as part of a netlink message indicating a L3 miss. Changing .sa.sa_family = AF_INET, to .sin.sin_family = AF_INET, fixes the problem. Signed-off-by: Gerhard Stenzel <gerhard.stenzel@de.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 451fd72 commit a45e92a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎drivers/net/vxlan.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb)
13271327
} else if (vxlan->flags & VXLAN_F_L3MISS) {
13281328
union vxlan_addr ipa = {
13291329
.sin.sin_addr.s_addr = tip,
1330-
.sa.sa_family = AF_INET,
1330+
.sin.sin_family = AF_INET,
13311331
};
13321332

13331333
vxlan_ip_miss(dev, &ipa);
@@ -1488,7 +1488,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb)
14881488
} else if (vxlan->flags & VXLAN_F_L3MISS) {
14891489
union vxlan_addr ipa = {
14901490
.sin6.sin6_addr = msg->target,
1491-
.sa.sa_family = AF_INET6,
1491+
.sin6.sin6_family = AF_INET6,
14921492
};
14931493

14941494
vxlan_ip_miss(dev, &ipa);
@@ -1521,7 +1521,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
15211521
if (!n && (vxlan->flags & VXLAN_F_L3MISS)) {
15221522
union vxlan_addr ipa = {
15231523
.sin.sin_addr.s_addr = pip->daddr,
1524-
.sa.sa_family = AF_INET,
1524+
.sin.sin_family = AF_INET,
15251525
};
15261526

15271527
vxlan_ip_miss(dev, &ipa);
@@ -1542,7 +1542,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
15421542
if (!n && (vxlan->flags & VXLAN_F_L3MISS)) {
15431543
union vxlan_addr ipa = {
15441544
.sin6.sin6_addr = pip6->daddr,
1545-
.sa.sa_family = AF_INET6,
1545+
.sin6.sin6_family = AF_INET6,
15461546
};
15471547

15481548
vxlan_ip_miss(dev, &ipa);

0 commit comments

Comments
 (0)