Skip to content

Commit 6a5f44d

Browse files
fabledDavid S. Miller
authored andcommitted
[IPV4] ip_gre: sendto/recvfrom NBMA address
When GRE tunnel is in NBMA mode, this patch allows an application to use a PF_PACKET socket to: - send a packet to specific NBMA address with sendto() - use recvfrom() to receive packet and check which NBMA address it came from This is required to implement properly NHRP over GRE tunnel. Signed-off-by: Timo Teras <timo.teras@iki.fi> Acked-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 16d14ef commit 6a5f44d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

net/ipv4/ip_gre.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,6 @@ static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu)
10331033
return 0;
10341034
}
10351035

1036-
#ifdef CONFIG_NET_IPGRE_BROADCAST
10371036
/* Nice toy. Unfortunately, useless in real life :-)
10381037
It allows to construct virtual multiprotocol broadcast "LAN"
10391038
over the Internet, provided multicast routing is tuned.
@@ -1092,10 +1091,19 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
10921091
return -t->hlen;
10931092
}
10941093

1094+
static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr)
1095+
{
1096+
struct iphdr *iph = (struct iphdr*) skb_mac_header(skb);
1097+
memcpy(haddr, &iph->saddr, 4);
1098+
return 4;
1099+
}
1100+
10951101
static const struct header_ops ipgre_header_ops = {
10961102
.create = ipgre_header,
1103+
.parse = ipgre_header_parse,
10971104
};
10981105

1106+
#ifdef CONFIG_NET_IPGRE_BROADCAST
10991107
static int ipgre_open(struct net_device *dev)
11001108
{
11011109
struct ip_tunnel *t = netdev_priv(dev);
@@ -1197,6 +1205,8 @@ static int ipgre_tunnel_init(struct net_device *dev)
11971205
dev->stop = ipgre_close;
11981206
}
11991207
#endif
1208+
} else {
1209+
dev->header_ops = &ipgre_header_ops;
12001210
}
12011211

12021212
if (!tdev && tunnel->parms.link)

0 commit comments

Comments
 (0)