Commit 125372fa authored by Jiri Benc's avatar Jiri Benc Committed by David S. Miller

gre: receive also TEB packets for lwtunnels

For ipgre interfaces in collect metadata mode, receive also traffic with
encapsulated Ethernet headers. The lwtunnel users are supposed to sort this
out correctly. This allows to have mixed Ethernet + L3-only traffic on the
same lwtunnel interface. This is the same way as VXLAN-GPE behaves.

To keep backwards compatibility and prevent any surprises, gretap interfaces
have priority in receiving packets with Ethernet headers.
Signed-off-by: default avatarJiri Benc <jbenc@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 244a797b
...@@ -160,6 +160,7 @@ struct tnl_ptk_info { ...@@ -160,6 +160,7 @@ struct tnl_ptk_info {
#define PACKET_RCVD 0 #define PACKET_RCVD 0
#define PACKET_REJECT 1 #define PACKET_REJECT 1
#define PACKET_NEXT 2
#define IP_TNL_HASH_BITS 7 #define IP_TNL_HASH_BITS 7
#define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS) #define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS)
......
...@@ -260,26 +260,20 @@ static __be32 tunnel_id_to_key(__be64 x) ...@@ -260,26 +260,20 @@ static __be32 tunnel_id_to_key(__be64 x)
#endif #endif
} }
static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi, static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
int hdr_len) struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)
{ {
struct net *net = dev_net(skb->dev);
struct metadata_dst *tun_dst = NULL; struct metadata_dst *tun_dst = NULL;
struct ip_tunnel_net *itn;
const struct iphdr *iph; const struct iphdr *iph;
struct ip_tunnel *tunnel; struct ip_tunnel *tunnel;
if (tpi->proto == htons(ETH_P_TEB))
itn = net_generic(net, gre_tap_net_id);
else
itn = net_generic(net, ipgre_net_id);
iph = ip_hdr(skb); iph = ip_hdr(skb);
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, tpi->flags, tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, tpi->flags,
iph->saddr, iph->daddr, tpi->key); iph->saddr, iph->daddr, tpi->key);
if (tunnel) { if (tunnel) {
if (iptunnel_pull_header(skb, hdr_len, tpi->proto, false) < 0) if (__iptunnel_pull_header(skb, hdr_len, tpi->proto,
raw_proto, false) < 0)
goto drop; goto drop;
skb_pop_mac_header(skb); skb_pop_mac_header(skb);
...@@ -297,13 +291,36 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi, ...@@ -297,13 +291,36 @@ static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error); ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
return PACKET_RCVD; return PACKET_RCVD;
} }
return PACKET_REJECT; return PACKET_NEXT;
drop: drop:
kfree_skb(skb); kfree_skb(skb);
return PACKET_RCVD; return PACKET_RCVD;
} }
static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
int hdr_len)
{
struct net *net = dev_net(skb->dev);
struct ip_tunnel_net *itn;
int res;
if (tpi->proto == htons(ETH_P_TEB))
itn = net_generic(net, gre_tap_net_id);
else
itn = net_generic(net, ipgre_net_id);
res = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
if (res == PACKET_NEXT && tpi->proto == htons(ETH_P_TEB)) {
/* ipgre tunnels in collect metadata mode should receive
* also ETH_P_TEB traffic.
*/
itn = net_generic(net, ipgre_net_id);
res = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
}
return res;
}
static int gre_rcv(struct sk_buff *skb) static int gre_rcv(struct sk_buff *skb)
{ {
struct tnl_ptk_info tpi; struct tnl_ptk_info tpi;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment