Skip to content

Commit bbe735e

Browse files
acmelDavid S. Miller
authored andcommitted
[SK_BUFF]: Introduce skb_network_offset()
For the quite common 'skb->nh.raw - skb->data' sequence. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e7dd65d commit bbe735e

18 files changed

Lines changed: 33 additions & 28 deletions

File tree

‎drivers/isdn/i4l/isdn_net.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ isdn_net_adjust_hdr(struct sk_buff *skb, struct net_device *dev)
11211121
if (!skb)
11221122
return;
11231123
if (lp->p_encap == ISDN_NET_ENCAP_ETHER) {
1124-
int pullsize = (ulong)skb->nh.raw - (ulong)skb->data - ETH_HLEN;
1124+
const int pullsize = skb_network_offset(skb) - ETH_HLEN;
11251125
if (pullsize > 0) {
11261126
printk(KERN_DEBUG "isdn_net: Pull junk %d\n", pullsize);
11271127
skb_pull(skb, pullsize);

‎drivers/net/atl1/atl1_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
13001300
~csum_tcpudp_magic(skb->nh.iph->saddr,
13011301
skb->nh.iph->daddr, 0,
13021302
IPPROTO_TCP, 0);
1303-
ipofst = skb->nh.raw - skb->data;
1303+
ipofst = skb_network_offset(skb);
13041304
if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
13051305
tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;
13061306

‎drivers/net/chelsio/sge.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
18651865

18661866
++st->tx_tso;
18671867

1868-
eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
1868+
eth_type = skb_network_offset(skb) == ETH_HLEN ?
18691869
CPL_ETH_II : CPL_ETH_II_VLAN;
18701870

18711871
hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));

‎drivers/net/cxgb3/sge.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
897897
d->flit[2] = 0;
898898
cntrl |= V_TXPKT_OPCODE(CPL_TX_PKT_LSO);
899899
hdr->cntrl = htonl(cntrl);
900-
eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
900+
eth_type = skb_network_offset(skb) == ETH_HLEN ?
901901
CPL_ETH_II : CPL_ETH_II_VLAN;
902902
tso_info |= V_LSO_ETH_TYPE(eth_type) |
903903
V_LSO_IPHDR_WORDS(skb->nh.iph->ihl) |

‎drivers/net/e1000/e1000_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2910,7 +2910,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
29102910
0);
29112911
ipcse = 0;
29122912
}
2913-
ipcss = skb->nh.raw - skb->data;
2913+
ipcss = skb_network_offset(skb);
29142914
ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
29152915
tucss = skb->h.raw - skb->data;
29162916
tucso = (void *)&(skb->h.th->check) - (void *)skb->data;

‎drivers/net/gianfar.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
952952
* frame (skb->data) and the start of the IP hdr.
953953
* l4os is the distance between the start of the
954954
* l3 hdr and the l4 hdr */
955-
fcb->l3os = (u16)(skb->nh.raw - skb->data - GMAC_FCB_LEN);
955+
fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
956956
fcb->l4os = (u16)(skb->h.raw - skb->nh.raw);
957957

958958
fcb->flags = flags;

‎drivers/net/ixgb/ixgb_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
11951195
skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
11961196
skb->nh.iph->daddr,
11971197
0, IPPROTO_TCP, 0);
1198-
ipcss = skb->nh.raw - skb->data;
1198+
ipcss = skb_network_offset(skb);
11991199
ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
12001200
ipcse = skb->h.raw - skb->data - 1;
12011201
tucss = skb->h.raw - skb->data;

‎drivers/net/netxen/netxen_nic_hw.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ void netxen_tso_check(struct netxen_adapter *adapter,
386386
}
387387
adapter->stats.xmitcsummed++;
388388
desc->tcp_hdr_offset = skb->h.raw - skb->data;
389-
desc->ip_hdr_offset = skb->nh.raw - skb->data;
389+
desc->ip_hdr_offset = skb_network_offset(skb);
390390
}
391391

392392
int netxen_is_flash_supported(struct netxen_adapter *adapter)

‎include/linux/skbuff.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,11 @@ static inline void skb_reset_network_header(struct sk_buff *skb)
965965
skb->nh.raw = skb->data;
966966
}
967967

968+
static inline int skb_network_offset(const struct sk_buff *skb)
969+
{
970+
return skb->nh.raw - skb->data;
971+
}
972+
968973
static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
969974
{
970975
return skb->mac.raw;

‎net/ax25/ax25_out.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
148148

149149
if (ka9qfrag == 1) {
150150
skb_reserve(skbn, frontlen + 2);
151-
skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data);
151+
skbn->nh.raw = skbn->data + skb_network_offset(skb);
152152
memcpy(skb_put(skbn, len), skb->data, len);
153153
p = skb_push(skbn, 2);
154154

@@ -161,7 +161,7 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
161161
}
162162
} else {
163163
skb_reserve(skbn, frontlen + 1);
164-
skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data);
164+
skbn->nh.raw = skbn->data + skb_network_offset(skb);
165165
memcpy(skb_put(skbn, len), skb->data, len);
166166
p = skb_push(skbn, 1);
167167
*p = AX25_P_TEXT;

0 commit comments

Comments
 (0)