Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cfe1fc77 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller
Browse files

[SK_BUFF]: Introduce skb_network_header_len



For the common sequence "skb->h.raw - skb->nh.raw", similar to skb->mac_len,
that is precalculated tho, don't think we need to bloat skb with one more
member, so just use this new helper, reducing the number of non-skbuff.h
references to the layer headers even more.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bff9b61c
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -953,7 +953,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
	 * l4os is the distance between the start of the
	 * l4os is the distance between the start of the
	 * l3 hdr and the l4 hdr */
	 * l3 hdr and the l4 hdr */
	fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
	fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN);
	fcb->l4os = (u16)(skb->h.raw - skb->nh.raw);
	fcb->l4os = skb_network_header_len(skb);


	fcb->flags = flags;
	fcb->flags = flags;
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -734,12 +734,12 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
		switch (ip_hdr(skb)->protocol) {
		switch (ip_hdr(skb)->protocol) {
		case IPPROTO_TCP:
		case IPPROTO_TCP:
			dflags |= XCT_MACTX_CSUM_TCP;
			dflags |= XCT_MACTX_CSUM_TCP;
			dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2);
			dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
			dflags |= XCT_MACTX_IPO(nh - skb->data);
			dflags |= XCT_MACTX_IPO(nh - skb->data);
			break;
			break;
		case IPPROTO_UDP:
		case IPPROTO_UDP:
			dflags |= XCT_MACTX_CSUM_UDP;
			dflags |= XCT_MACTX_CSUM_UDP;
			dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2);
			dflags |= XCT_MACTX_IPH(skb_network_header_len(skb) >> 2);
			dflags |= XCT_MACTX_IPO(nh - skb->data);
			dflags |= XCT_MACTX_IPO(nh - skb->data);
			break;
			break;
		}
		}
+5 −0
Original line number Original line Diff line number Diff line
@@ -992,6 +992,11 @@ static inline int skb_network_offset(const struct sk_buff *skb)
	return skb->nh.raw - skb->data;
	return skb->nh.raw - skb->data;
}
}


static inline u32 skb_network_header_len(const struct sk_buff *skb)
{
	return skb->h.raw - skb->nh.raw;
}

static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
{
{
	return skb->mac.raw;
	return skb->mac.raw;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1906,7 +1906,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
		skb_reserve(nskb, headroom);
		skb_reserve(nskb, headroom);
		skb_reset_mac_header(nskb);
		skb_reset_mac_header(nskb);
		skb_set_network_header(nskb, skb->mac_len);
		skb_set_network_header(nskb, skb->mac_len);
		nskb->h.raw = nskb->nh.raw + (skb->h.raw - skb->nh.raw);
		nskb->h.raw = nskb->nh.raw + skb_network_header_len(skb);
		memcpy(skb_put(nskb, doffset), skb->data, doffset);
		memcpy(skb_put(nskb, doffset), skb->data, doffset);


		if (!sg) {
		if (!sg) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -1187,7 +1187,7 @@ int ip_push_pending_frames(struct sock *sk)
	if (skb->data < skb_network_header(skb))
	if (skb->data < skb_network_header(skb))
		__skb_pull(skb, skb_network_offset(skb));
		__skb_pull(skb, skb_network_offset(skb));
	while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
	while ((tmp_skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) {
		__skb_pull(tmp_skb, skb->h.raw - skb->nh.raw);
		__skb_pull(tmp_skb, skb_network_header_len(skb));
		*tail_skb = tmp_skb;
		*tail_skb = tmp_skb;
		tail_skb = &(tmp_skb->next);
		tail_skb = &(tmp_skb->next);
		skb->len += tmp_skb->len;
		skb->len += tmp_skb->len;
Loading