Skip to content

Commit

Permalink
[SK_BUFF]: unions of just one member don't get anything done, kill them
Browse files Browse the repository at this point in the history
Renaming skb->h to skb->transport_header, skb->nh to skb->network_header and
skb->mac to skb->mac_header, to match the names of the associated helpers
(skb[_[re]set]_{transport,network,mac}_header).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arnaldo Carvalho de Melo authored and David S. Miller committed Apr 26, 2007
1 parent cfe1fc7 commit b0e380b
Show file tree
Hide file tree
Showing 46 changed files with 162 additions and 165 deletions.
17 changes: 11 additions & 6 deletions drivers/net/arcnet/arcnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,12 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
* real header when we do rebuild_header.
*/
*(uint16_t *) skb_push(skb, 2) = type;
if (skb->nh.raw - skb->mac.raw != 2)
/*
* XXX: Why not use skb->mac_len?
*/
if (skb->network_header - skb->mac_header != 2)
BUGMSG(D_NORMAL, "arcnet_header: Yikes! diff (%d) is not 2!\n",
(int)(skb->nh.raw - skb->mac.raw));
(int)(skb->network_header - skb->mac_header));
return -2; /* return error -- can't transmit yet! */
}
else {
Expand Down Expand Up @@ -554,11 +557,13 @@ static int arcnet_rebuild_header(struct sk_buff *skb)
unsigned short type;
uint8_t daddr=0;
struct ArcProto *proto;

if (skb->nh.raw - skb->mac.raw != 2) {
/*
* XXX: Why not use skb->mac_len?
*/
if (skb->network_header - skb->mac_header != 2) {
BUGMSG(D_NORMAL,
"rebuild_header: shouldn't be here! (hdrsize=%d)\n",
(int)(skb->nh.raw - skb->mac.raw));
"rebuild_header: shouldn't be here! (hdrsize=%d)\n",
(int)(skb->network_header - skb->mac_header));
return 0;
}
type = *(uint16_t *) skb_pull(skb, 2);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/bonding/bond_3ad.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ static int ad_lacpdu_send(struct port *port)

skb->dev = slave->dev;
skb_reset_mac_header(skb);
skb->nh.raw = skb->mac.raw + ETH_HLEN;
skb->network_header = skb->mac_header + ETH_HLEN;
skb->protocol = PKT_TYPE_LACPDU;
skb->priority = TC_PRIO_CONTROL;

Expand Down Expand Up @@ -929,7 +929,7 @@ static int ad_marker_send(struct port *port, struct marker *marker)

skb->dev = slave->dev;
skb_reset_mac_header(skb);
skb->nh.raw = skb->mac.raw + ETH_HLEN;
skb->network_header = skb->mac_header + ETH_HLEN;
skb->protocol = PKT_TYPE_LACPDU;

marker_header = (struct marker_header *)skb_put(skb, length);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
memcpy(data, &pkt, size);

skb_reset_mac_header(skb);
skb->nh.raw = skb->mac.raw + ETH_HLEN;
skb->network_header = skb->mac_header + ETH_HLEN;
skb->protocol = pkt.type;
skb->priority = TC_PRIO_CONTROL;
skb->dev = slave->dev;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/hostap/hostap_80211_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
skb2->protocol = __constant_htons(ETH_P_802_3);
skb_reset_mac_header(skb2);
skb_reset_network_header(skb2);
/* skb2->nh.raw += ETH_HLEN; */
/* skb2->network_header += ETH_HLEN; */
dev_queue_xmit(skb2);
}

Expand Down
4 changes: 2 additions & 2 deletions include/linux/if_vlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
veth->h_vlan_TCI = htons(tag);

skb->protocol = __constant_htons(ETH_P_8021Q);
skb->mac.raw -= VLAN_HLEN;
skb->nh.raw -= VLAN_HLEN;
skb->mac_header -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;

return skb;
}
Expand Down
49 changes: 20 additions & 29 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
* NONE: skb is checksummed by protocol or csum is not required.
*
* PARTIAL: device is required to csum packet as seen by hard_start_xmit
* from skb->h.raw to the end and to record the checksum
* at skb->h.raw+skb->csum.
* from skb->transport_header to the end and to record the checksum
* at skb->transport_header + skb->csum.
*
* Device must show its capabilities in dev->features, set
* at device setup time.
Expand Down Expand Up @@ -188,8 +188,8 @@ enum {
* @dev: Device we arrived on/are leaving by
* @iif: ifindex of device we arrived on
* @h: Transport layer header
* @nh: Network layer header
* @mac: Link layer header
* @network_header: Network layer header
* @mac_header: Link layer header
* @dst: destination entry
* @sp: the security path, used for xfrm
* @cb: Control buffer. Free for use by every layer. Put private vars here
Expand Down Expand Up @@ -236,18 +236,9 @@ struct sk_buff {
int iif;
/* 4 byte hole on 64 bit*/

union {
unsigned char *raw;
} h;

union {
unsigned char *raw;
} nh;

union {
unsigned char *raw;
} mac;

unsigned char *transport_header;
unsigned char *network_header;
unsigned char *mac_header;
struct dst_entry *dst;
struct sec_path *sp;

Expand Down Expand Up @@ -953,68 +944,68 @@ static inline void skb_reserve(struct sk_buff *skb, int len)

static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
{
return skb->h.raw;
return skb->transport_header;
}

static inline void skb_reset_transport_header(struct sk_buff *skb)
{
skb->h.raw = skb->data;
skb->transport_header = skb->data;
}

static inline void skb_set_transport_header(struct sk_buff *skb,
const int offset)
{
skb->h.raw = skb->data + offset;
skb->transport_header = skb->data + offset;
}

static inline int skb_transport_offset(const struct sk_buff *skb)
{
return skb->h.raw - skb->data;
return skb->transport_header - skb->data;
}

static inline unsigned char *skb_network_header(const struct sk_buff *skb)
{
return skb->nh.raw;
return skb->network_header;
}

static inline void skb_reset_network_header(struct sk_buff *skb)
{
skb->nh.raw = skb->data;
skb->network_header = skb->data;
}

static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
{
skb->nh.raw = skb->data + offset;
skb->network_header = skb->data + offset;
}

static inline int skb_network_offset(const struct sk_buff *skb)
{
return skb->nh.raw - skb->data;
return skb->network_header - skb->data;
}

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

static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
{
return skb->mac.raw;
return skb->mac_header;
}

static inline int skb_mac_header_was_set(const struct sk_buff *skb)
{
return skb->mac.raw != NULL;
return skb->mac_header != NULL;
}

static inline void skb_reset_mac_header(struct sk_buff *skb)
{
skb->mac.raw = skb->data;
skb->mac_header = skb->data;
}

static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
{
skb->mac.raw = skb->data + offset;
skb->mac_header = skb->data + offset;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion net/802/psnap.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev,
proto = find_snap_client(skb_transport_header(skb));
if (proto) {
/* Pass the frame on. */
skb->h.raw += 5;
skb->transport_header += 5;
skb_pull_rcsum(skb, 5);
rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev);
} else {
Expand Down
2 changes: 1 addition & 1 deletion net/8021q/vlan_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb)
/* Lifted from Gleb's VLAN code... */
memmove(skb->data - ETH_HLEN,
skb->data - VLAN_ETH_HLEN, 12);
skb->mac.raw += VLAN_HLEN;
skb->mac_header += VLAN_HLEN;
}
}

Expand Down
8 changes: 4 additions & 4 deletions net/appletalk/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,10 +1383,10 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
* @pt - packet type
*
* Receive a packet (in skb) from device dev. This has come from the SNAP
* decoder, and on entry skb->h.raw is the DDP header, skb->len is the DDP
* header, skb->len is the DDP length. The physical headers have been
* extracted. PPP should probably pass frames marked as for this layer.
* [ie ARPHRD_ETHERTALK]
* decoder, and on entry skb->transport_header is the DDP header, skb->len
* is the DDP header, skb->len is the DDP length. The physical headers
* have been extracted. PPP should probably pass frames marked as for this
* layer. [ie ARPHRD_ETHERTALK]
*/
static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
Expand Down
24 changes: 12 additions & 12 deletions net/bridge/br_netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
skb->dev = nf_bridge->physindev;
if (skb->protocol == htons(ETH_P_8021Q)) {
skb_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;
}
NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
br_handle_frame_finish, 1);
Expand Down Expand Up @@ -255,7 +255,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
else {
if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN;
skb->network_header += VLAN_HLEN;
}
skb->dst->output(skb);
}
Expand Down Expand Up @@ -325,7 +325,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
if (skb->protocol ==
htons(ETH_P_8021Q)) {
skb_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;
}
NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING,
skb, skb->dev, NULL,
Expand All @@ -344,7 +344,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
skb->dev = nf_bridge->physindev;
if (skb->protocol == htons(ETH_P_8021Q)) {
skb_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;
}
NF_HOOK_THRESH(PF_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
br_handle_frame_finish, 1);
Expand Down Expand Up @@ -497,7 +497,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,

if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull_rcsum(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN;
skb->network_header += VLAN_HLEN;
}
return br_nf_pre_routing_ipv6(hook, skb, in, out, okfn);
}
Expand All @@ -514,7 +514,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,

if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull_rcsum(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN;
skb->network_header += VLAN_HLEN;
}

if (!pskb_may_pull(skb, sizeof(struct iphdr)))
Expand Down Expand Up @@ -595,7 +595,7 @@ static int br_nf_forward_finish(struct sk_buff *skb)
}
if (skb->protocol == htons(ETH_P_8021Q)) {
skb_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;
}
NF_HOOK_THRESH(PF_BRIDGE, NF_BR_FORWARD, skb, in,
skb->dev, br_forward_finish, 1);
Expand Down Expand Up @@ -631,7 +631,7 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff **pskb,

if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull(*pskb, VLAN_HLEN);
(*pskb)->nh.raw += VLAN_HLEN;
(*pskb)->network_header += VLAN_HLEN;
}

nf_bridge = skb->nf_bridge;
Expand Down Expand Up @@ -667,13 +667,13 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff **pskb,
if (!IS_VLAN_ARP(skb))
return NF_ACCEPT;
skb_pull(*pskb, VLAN_HLEN);
(*pskb)->nh.raw += VLAN_HLEN;
(*pskb)->network_header += VLAN_HLEN;
}

if (arp_hdr(skb)->ar_pln != 4) {
if (IS_VLAN_ARP(skb)) {
skb_push(*pskb, VLAN_HLEN);
(*pskb)->nh.raw -= VLAN_HLEN;
(*pskb)->network_header -= VLAN_HLEN;
}
return NF_ACCEPT;
}
Expand Down Expand Up @@ -723,7 +723,7 @@ static unsigned int br_nf_local_out(unsigned int hook, struct sk_buff **pskb,
}
if (skb->protocol == htons(ETH_P_8021Q)) {
skb_push(skb, VLAN_HLEN);
skb->nh.raw -= VLAN_HLEN;
skb->network_header -= VLAN_HLEN;
}

NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, realindev, skb->dev,
Expand Down Expand Up @@ -790,7 +790,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff **pskb,

if (skb->protocol == htons(ETH_P_8021Q)) {
skb_pull(skb, VLAN_HLEN);
skb->nh.raw += VLAN_HLEN;
skb->network_header += VLAN_HLEN;
}

nf_bridge_save_header(skb);
Expand Down
6 changes: 3 additions & 3 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
skb_reset_network_header(skb2);
}

skb2->h.raw = skb2->nh.raw;
skb2->transport_header = skb2->network_header;
skb2->pkt_type = PACKET_OUTGOING;
ptype->func(skb2, skb->dev, ptype, skb->dev);
}
Expand Down Expand Up @@ -1207,7 +1207,7 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
BUG_ON(skb_shinfo(skb)->frag_list);

skb_reset_mac_header(skb);
skb->mac_len = skb->nh.raw - skb->mac.raw;
skb->mac_len = skb->network_header - skb->mac_header;
__skb_pull(skb, skb->mac_len);

if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
Expand Down Expand Up @@ -1774,7 +1774,7 @@ int netif_receive_skb(struct sk_buff *skb)

skb_reset_network_header(skb);
skb_reset_transport_header(skb);
skb->mac_len = skb->nh.raw - skb->mac.raw;
skb->mac_len = skb->network_header - skb->mac_header;

pt_prev = NULL;

Expand Down
Loading

0 comments on commit b0e380b

Please sign in to comment.