From 2060f60afee2a8f970ae263e17595d51ab7eb530 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 10 Feb 2014 14:51:30 +0100 Subject: [PATCH] gtp: move gtp header setup before UDP header This is just another cleanup to prepare IPv6 support. Move code to the correct context, just before pushing and setting up the UDP header. --- gtp.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/gtp.c b/gtp.c index 44353ef..8027ca0 100644 --- a/gtp.c +++ b/gtp.c @@ -562,22 +562,6 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) goto tx_error; } - payload_len = skb->len; - - /* Pushing GTP header */ - pr_info("pushing gtp header\n"); - switch (pctx->gtp_version) { - case GTP_V0: - gtp0_push_header(skb, pctx, payload_len); - break; - case GTP_V1: - gtp1u_push_header(skb, pctx, payload_len); - break; - default: - /* Should not happen */ - goto out; - } - memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | IPSKB_REROUTED); @@ -612,6 +596,19 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) } #endif + /* Annotate length of the encapsulated packet */ + payload_len = skb->len; + + /* Push down GTP header */ + switch (pctx->gtp_version) { + case GTP_V0: + gtp0_push_header(skb, pctx, payload_len); + break; + case GTP_V1: + gtp1u_push_header(skb, pctx, payload_len); + break; + } + /* Push down and install the UDP header. */ skb_push(skb, sizeof(struct udphdr)); skb_reset_transport_header(skb); @@ -652,9 +649,6 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) err = ip_local_out(skb); gtp_iptunnel_xmit_stats(err, &dev->stats, dev->tstats); - return NETDEV_TX_OK; -out: - rcu_read_unlock_bh(); return NETDEV_TX_OK; tx_error: rcu_read_unlock_bh();