Skip to content

Commit 93ca3bb

Browse files
fableddavem330
authored andcommitted
net: gre: provide multicast mappings for ipv4 and ipv6
My commit 6d55cb9 (gre: fix hard header destination address checking) broke multicast. The reason is that ip_gre used to get ipgre_header() calls with zero destination if we have NOARP or multicast destination. Instead the actual target was decided at ipgre_tunnel_xmit() time based on per-protocol dissection. Instead of allowing the "abuse" of ->header() calls with invalid destination, this creates multicast mappings for ip_gre. This also fixes "ip neigh show nud noarp" to display the proper multicast mappings used by the gre device. Reported-by: Doug Kehn <rdkehn@yahoo.com> Signed-off-by: Timo Teräs <timo.teras@iki.fi> Acked-by: Doug Kehn <rdkehn@yahoo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1459a3c commit 93ca3bb

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎include/net/if_inet6.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,21 @@ static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
286286
buf[9] = broadcast[9];
287287
memcpy(buf + 10, addr->s6_addr + 6, 10);
288288
}
289+
290+
static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
291+
const unsigned char *broadcast, char *buf)
292+
{
293+
if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) {
294+
memcpy(buf, broadcast, 4);
295+
} else {
296+
/* v4mapped? */
297+
if ((addr->s6_addr32[0] | addr->s6_addr32[1] |
298+
(addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0)
299+
return -EINVAL;
300+
memcpy(buf, &addr->s6_addr32[3], 4);
301+
}
302+
return 0;
303+
}
304+
289305
#endif
290306
#endif

‎include/net/ip.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, ch
339339
buf[16] = addr & 0x0f;
340340
}
341341

342+
static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
343+
{
344+
if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0)
345+
memcpy(buf, broadcast, 4);
346+
else
347+
memcpy(buf, &naddr, sizeof(naddr));
348+
}
349+
342350
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
343351
#include <linux/ipv6.h>
344352
#endif

‎net/ipv4/arp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir)
215215
case ARPHRD_INFINIBAND:
216216
ip_ib_mc_map(addr, dev->broadcast, haddr);
217217
return 0;
218+
case ARPHRD_IPGRE:
219+
ip_ipgre_mc_map(addr, dev->broadcast, haddr);
220+
return 0;
218221
default:
219222
if (dir) {
220223
memcpy(haddr, dev->broadcast, dev->addr_len);

‎net/ipv6/ndisc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int d
341341
case ARPHRD_INFINIBAND:
342342
ipv6_ib_mc_map(addr, dev->broadcast, buf);
343343
return 0;
344+
case ARPHRD_IPGRE:
345+
return ipv6_ipgre_mc_map(addr, dev->broadcast, buf);
344346
default:
345347
if (dir) {
346348
memcpy(buf, dev->broadcast, dev->addr_len);

0 commit comments

Comments
 (0)