aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_tunnel.c
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2013-06-17 20:50:02 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-19 21:07:41 -0400
commit3d7b46cd20e300bd6989fb1f43d46f1b9645816e (patch)
treeb8a063f8ecb7e380f0e1672a60815ff48c3f9b56 /net/ipv4/ip_tunnel.c
parent0e6fbc5b6c6218987c93b8c7ca60cf786062899d (diff)
ip_tunnel: push generic protocol handling to ip_tunnel module.
Process skb tunnel header before sending packet to protocol handler. this allows code sharing between gre and ovs gre modules. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_tunnel.c')
-rw-r--r--net/ipv4/ip_tunnel.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index a06a2ed49597..bd227e5ea9da 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -408,13 +408,6 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
408 const struct iphdr *iph = ip_hdr(skb); 408 const struct iphdr *iph = ip_hdr(skb);
409 int err; 409 int err;
410 410
411 secpath_reset(skb);
412
413 skb->protocol = tpi->proto;
414
415 skb->mac_header = skb->network_header;
416 __pskb_pull(skb, tunnel->hlen);
417 skb_postpull_rcsum(skb, skb_transport_header(skb), tunnel->hlen);
418#ifdef CONFIG_NET_IPGRE_BROADCAST 411#ifdef CONFIG_NET_IPGRE_BROADCAST
419 if (ipv4_is_multicast(iph->daddr)) { 412 if (ipv4_is_multicast(iph->daddr)) {
420 /* Looped back packet, drop it! */ 413 /* Looped back packet, drop it! */
@@ -442,23 +435,6 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
442 tunnel->i_seqno = ntohl(tpi->seq) + 1; 435 tunnel->i_seqno = ntohl(tpi->seq) + 1;
443 } 436 }
444 437
445 /* Warning: All skb pointers will be invalidated! */
446 if (tunnel->dev->type == ARPHRD_ETHER) {
447 if (!pskb_may_pull(skb, ETH_HLEN)) {
448 tunnel->dev->stats.rx_length_errors++;
449 tunnel->dev->stats.rx_errors++;
450 goto drop;
451 }
452
453 iph = ip_hdr(skb);
454 skb->protocol = eth_type_trans(skb, tunnel->dev);
455 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
456 }
457
458 skb->pkt_type = PACKET_HOST;
459 __skb_tunnel_rx(skb, tunnel->dev);
460
461 skb_reset_network_header(skb);
462 err = IP_ECN_decapsulate(iph, skb); 438 err = IP_ECN_decapsulate(iph, skb);
463 if (unlikely(err)) { 439 if (unlikely(err)) {
464 if (log_ecn_error) 440 if (log_ecn_error)
@@ -477,6 +453,12 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
477 tstats->rx_bytes += skb->len; 453 tstats->rx_bytes += skb->len;
478 u64_stats_update_end(&tstats->syncp); 454 u64_stats_update_end(&tstats->syncp);
479 455
456 if (tunnel->dev->type == ARPHRD_ETHER) {
457 skb->protocol = eth_type_trans(skb, tunnel->dev);
458 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
459 } else {
460 skb->dev = tunnel->dev;
461 }
480 gro_cells_receive(&tunnel->gro_cells, skb); 462 gro_cells_receive(&tunnel->gro_cells, skb);
481 return 0; 463 return 0;
482 464