Skip to content

Commit

Permalink
[SK_BUFF]: Introduce ipv6_hdr(), remove skb->nh.ipv6h
Browse files Browse the repository at this point in the history
Now the skb->nh union has just one member, .raw, i.e. it is just like the
skb->mac union, strange, no? I'm just leaving it like that till the transport
layer is done with, when we'll rename skb->mac.raw to skb->mac_header (or
->mac_header_offset?), ditto for ->{h,nh}.

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
acmel authored and David S. Miller committed Apr 26, 2007
1 parent d0a92be commit 0660e03
Show file tree
Hide file tree
Showing 59 changed files with 296 additions and 292 deletions.
4 changes: 2 additions & 2 deletions drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,8 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
break;
}

hash_start = (char*)&(skb->nh.ipv6h->daddr);
hash_size = sizeof(skb->nh.ipv6h->daddr);
hash_start = (char *)&(ipv6_hdr(skb)->daddr);
hash_size = sizeof(ipv6_hdr(skb)->daddr);
break;
case ETH_P_IPX:
if (ipx_hdr(skb)->ipx_checksum !=
Expand Down
10 changes: 4 additions & 6 deletions drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2899,13 +2899,11 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
cmd_length = E1000_TXD_CMD_IP;
ipcse = skb->h.raw - skb->data - 1;
} else if (skb->protocol == htons(ETH_P_IPV6)) {
skb->nh.ipv6h->payload_len = 0;
ipv6_hdr(skb)->payload_len = 0;
skb->h.th->check =
~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
&skb->nh.ipv6h->daddr,
0,
IPPROTO_TCP,
0);
~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
&ipv6_hdr(skb)->daddr,
0, IPPROTO_TCP, 0);
ipcse = 0;
}
ipcss = skb_network_offset(skb);
Expand Down
8 changes: 5 additions & 3 deletions drivers/s390/net/qeth_eddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
skb->h.raw,
skb->h.th->doff * 4);
else
eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.ipv6h,
sizeof(struct ipv6hdr),
(u8 *)skb->h.th, skb->h.th->doff*4);
eddp = qeth_eddp_create_eddp_data(qhdr,
skb_network_header(skb),
sizeof(struct ipv6hdr),
skb->h.raw,
skb->h.th->doff * 4);

if (eddp == NULL) {
QETH_DBF_TEXT(trace, 2, "eddpfcnm");
Expand Down
3 changes: 2 additions & 1 deletion drivers/s390/net/qeth_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4053,7 +4053,8 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
skb->dst->neighbour->primary_key, 16);
} else {
/* fill in destination address used in ip header */
memcpy(hdr->hdr.l3.dest_addr, &skb->nh.ipv6h->daddr, 16);
memcpy(hdr->hdr.l3.dest_addr,
&ipv6_hdr(skb)->daddr, 16);
}
} else { /* passthrough */
if((skb->dev->type == ARPHRD_IEEE802_TR) &&
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/net/qeth_tso.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static inline void
qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
{
struct iphdr *iph = ip_hdr(skb);
struct ipv6hdr *ip6h = skb->nh.ipv6h;
struct ipv6hdr *ip6h = ipv6_hdr(skb);
struct tcphdr *tcph = skb->h.th;

tcph->check = 0;
Expand Down
5 changes: 5 additions & 0 deletions include/linux/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ enum {
#include <net/if_inet6.h> /* struct ipv6_mc_socklist */
#include <net/inet_sock.h>

static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
{
return (struct ipv6hdr *)skb_network_header(skb);
}

/*
This structure contains results of exthdrs parsing
as offsets from skb->nh.
Expand Down
1 change: 0 additions & 1 deletion include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ struct sk_buff {
} h;

union {
struct ipv6hdr *ipv6h;
unsigned char *raw;
} nh;

Expand Down
2 changes: 1 addition & 1 deletion include/net/inet_ecn.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
case __constant_htons(ETH_P_IPV6):
if (skb_network_header(skb) + sizeof(struct ipv6hdr) <=
skb->tail)
return IP6_ECN_set_ce(skb->nh.ipv6h);
return IP6_ECN_set_ce(ipv6_hdr(skb));
break;
}

Expand Down
6 changes: 3 additions & 3 deletions net/bridge/br_netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static struct net_device *setup_pre_routing(struct sk_buff *skb)
/* We only check the length. A bridge shouldn't do any hop-by-hop stuff anyway */
static int check_hbh_len(struct sk_buff *skb)
{
unsigned char *raw = (u8 *) (skb->nh.ipv6h + 1);
unsigned char *raw = (u8 *)(ipv6_hdr(skb) + 1);
u32 pkt_len;
const unsigned char *nh = skb_network_header(skb);
int off = raw - nh;
Expand Down Expand Up @@ -400,7 +400,7 @@ static int check_hbh_len(struct sk_buff *skb)
goto bad;
pkt_len = ntohl(*(__be32 *) (nh + off + 2));
if (pkt_len <= IPV6_MAXPLEN ||
skb->nh.ipv6h->payload_len)
ipv6_hdr(skb)->payload_len)
goto bad;
if (pkt_len > skb->len - sizeof(struct ipv6hdr))
goto bad;
Expand Down Expand Up @@ -441,7 +441,7 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook,
if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
goto inhdr_error;

hdr = skb->nh.ipv6h;
hdr = ipv6_hdr(skb);

if (hdr->version != 6)
goto inhdr_error;
Expand Down
2 changes: 1 addition & 1 deletion net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2736,7 +2736,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
skb->protocol = protocol;
skb->dev = odev;
skb->pkt_type = PACKET_HOST;
skb->nh.ipv6h = iph;
skb->nh.raw = (unsigned char *)iph;
skb->h.uh = udph;

if (pkt_dev->nfrags <= 0)
Expand Down
32 changes: 17 additions & 15 deletions net/dccp/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ static inline __u32 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,

static inline __u32 dccp_v6_init_sequence(struct sk_buff *skb)
{
return secure_dccpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32,
skb->nh.ipv6h->saddr.s6_addr32,
return secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,
ipv6_hdr(skb)->saddr.s6_addr32,
dccp_hdr(skb)->dccph_dport,
dccp_hdr(skb)->dccph_sport );

Expand Down Expand Up @@ -313,6 +313,7 @@ static void dccp_v6_reqsk_destructor(struct request_sock *req)
static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
{
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
struct ipv6hdr *rxip6h;
const u32 dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
sizeof(struct dccp_hdr_ext) +
sizeof(struct dccp_hdr_reset);
Expand Down Expand Up @@ -352,12 +353,13 @@ static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq);

dccp_csum_outgoing(skb);
dh->dccph_checksum = dccp_v6_csum_finish(skb, &rxskb->nh.ipv6h->saddr,
&rxskb->nh.ipv6h->daddr);
rxip6h = ipv6_hdr(rxskb);
dh->dccph_checksum = dccp_v6_csum_finish(skb, &rxip6h->saddr,
&rxip6h->daddr);

memset(&fl, 0, sizeof(fl));
ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr);
ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr);
ipv6_addr_copy(&fl.fl6_dst, &rxip6h->saddr);
ipv6_addr_copy(&fl.fl6_src, &rxip6h->daddr);

fl.proto = IPPROTO_DCCP;
fl.oif = inet6_iif(rxskb);
Expand Down Expand Up @@ -390,7 +392,7 @@ static struct request_sock_ops dccp6_request_sock_ops = {
static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
{
const struct dccp_hdr *dh = dccp_hdr(skb);
const struct ipv6hdr *iph = skb->nh.ipv6h;
const struct ipv6hdr *iph = ipv6_hdr(skb);
struct sock *nsk;
struct request_sock **prev;
/* Find possible connection requests. */
Expand Down Expand Up @@ -460,8 +462,8 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
goto drop_and_free;

ireq6 = inet6_rsk(req);
ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr);
ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr);
ipv6_addr_copy(&ireq6->rmt_addr, &ipv6_hdr(skb)->saddr);
ipv6_addr_copy(&ireq6->loc_addr, &ipv6_hdr(skb)->daddr);
ireq6->pktopts = NULL;

if (ipv6_opt_accepted(sk, skb) ||
Expand Down Expand Up @@ -546,7 +548,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
newnp->pktoptions = NULL;
newnp->opt = NULL;
newnp->mcast_oif = inet6_iif(skb);
newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;

/*
* No need to charge this sock to the relevant IPv6 refcnt debug socks count
Expand Down Expand Up @@ -653,7 +655,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
}
newnp->opt = NULL;
newnp->mcast_oif = inet6_iif(skb);
newnp->mcast_hops = skb->nh.ipv6h->hop_limit;
newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;

/*
* Clone native IPv6 options from listening socket (if any)
Expand Down Expand Up @@ -826,8 +828,8 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
goto discard_it;

/* Step 1: If header checksum is incorrect, drop packet and return. */
if (dccp_v6_csum_finish(skb, &skb->nh.ipv6h->saddr,
&skb->nh.ipv6h->daddr)) {
if (dccp_v6_csum_finish(skb, &ipv6_hdr(skb)->saddr,
&ipv6_hdr(skb)->daddr)) {
DCCP_WARN("dropped packet with invalid checksum\n");
goto discard_it;
}
Expand All @@ -844,9 +846,9 @@ static int dccp_v6_rcv(struct sk_buff **pskb)

/* Step 2:
* Look up flow ID in table and get corresponding socket */
sk = __inet6_lookup(&dccp_hashinfo, &skb->nh.ipv6h->saddr,
sk = __inet6_lookup(&dccp_hashinfo, &ipv6_hdr(skb)->saddr,
dh->dccph_sport,
&skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport),
&ipv6_hdr(skb)->daddr, ntohs(dh->dccph_dport),
inet6_iif(skb));
/*
* Step 2:
Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ static inline void ipgre_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
if (skb->protocol == htons(ETH_P_IP)) {
IP_ECN_set_ce(ip_hdr(skb));
} else if (skb->protocol == htons(ETH_P_IPV6)) {
IP6_ECN_set_ce(skb->nh.ipv6h);
IP6_ECN_set_ce(ipv6_hdr(skb));
}
}
}
Expand Down Expand Up @@ -721,7 +721,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
addr_type = ipv6_addr_type(addr6);

if (addr_type == IPV6_ADDR_ANY) {
addr6 = &skb->nh.ipv6h->daddr;
addr6 = &ipv6_hdr(skb)->daddr;
addr_type = ipv6_addr_type(addr6);
}

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/xfrm4_mode_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
{
if (INET_ECN_is_ce(iph->tos))
IP6_ECN_set_ce(skb->nh.ipv6h);
IP6_ECN_set_ce(ipv6_hdr(skb));
}

/* Add encapsulation header.
Expand Down
14 changes: 8 additions & 6 deletions net/ipv6/ah6.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
*/

struct ipv6_auth_hdr *ah;
struct ipv6hdr *ip6h;
struct ah_data *ahp;
unsigned char *tmp_hdr = NULL;
u16 hdr_len;
Expand Down Expand Up @@ -357,13 +358,14 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
tmp_hdr = kmemdup(skb_network_header(skb), hdr_len, GFP_ATOMIC);
if (!tmp_hdr)
goto out;
if (ipv6_clear_mutable_options(skb->nh.ipv6h, hdr_len, XFRM_POLICY_IN))
ip6h = ipv6_hdr(skb);
if (ipv6_clear_mutable_options(ip6h, hdr_len, XFRM_POLICY_IN))
goto free_out;
skb->nh.ipv6h->priority = 0;
skb->nh.ipv6h->flow_lbl[0] = 0;
skb->nh.ipv6h->flow_lbl[1] = 0;
skb->nh.ipv6h->flow_lbl[2] = 0;
skb->nh.ipv6h->hop_limit = 0;
ip6h->priority = 0;
ip6h->flow_lbl[0] = 0;
ip6h->flow_lbl[1] = 0;
ip6h->flow_lbl[2] = 0;
ip6h->hop_limit = 0;

{
u8 auth_data[MAX_AH_AUTH_LEN];
Expand Down
16 changes: 8 additions & 8 deletions net/ipv6/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info)

skb_put(skb, sizeof(struct ipv6hdr));
skb_reset_network_header(skb);
iph = skb->nh.ipv6h;
iph = ipv6_hdr(skb);
ipv6_addr_copy(&iph->daddr, &fl->fl6_dst);

serr = SKB_EXT_ERR(skb);
Expand Down Expand Up @@ -340,7 +340,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
sin->sin6_flowinfo = 0;
sin->sin6_scope_id = 0;
if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP6) {
ipv6_addr_copy(&sin->sin6_addr, &skb->nh.ipv6h->saddr);
ipv6_addr_copy(&sin->sin6_addr, &ipv6_hdr(skb)->saddr);
if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb);
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
Expand Down Expand Up @@ -391,17 +391,17 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
struct in6_pktinfo src_info;

src_info.ipi6_ifindex = opt->iif;
ipv6_addr_copy(&src_info.ipi6_addr, &skb->nh.ipv6h->daddr);
ipv6_addr_copy(&src_info.ipi6_addr, &ipv6_hdr(skb)->daddr);
put_cmsg(msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info);
}

if (np->rxopt.bits.rxhlim) {
int hlim = skb->nh.ipv6h->hop_limit;
int hlim = ipv6_hdr(skb)->hop_limit;
put_cmsg(msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim);
}

if (np->rxopt.bits.rxtclass) {
int tclass = (ntohl(*(__be32 *)skb->nh.ipv6h) >> 20) & 0xff;
int tclass = (ntohl(*(__be32 *)ipv6_hdr(skb)) >> 20) & 0xff;
put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
}

Expand All @@ -428,7 +428,7 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
* IPV6_RECVDSTOPTS is more generic. --yoshfuji
*/
unsigned int off = sizeof(struct ipv6hdr);
u8 nexthdr = skb->nh.ipv6h->nexthdr;
u8 nexthdr = ipv6_hdr(skb)->nexthdr;

while (off <= opt->lastopt) {
unsigned len;
Expand Down Expand Up @@ -466,11 +466,11 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
struct in6_pktinfo src_info;

src_info.ipi6_ifindex = opt->iif;
ipv6_addr_copy(&src_info.ipi6_addr, &skb->nh.ipv6h->daddr);
ipv6_addr_copy(&src_info.ipi6_addr, &ipv6_hdr(skb)->daddr);
put_cmsg(msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info);
}
if (np->rxopt.bits.rxohlim) {
int hlim = skb->nh.ipv6h->hop_limit;
int hlim = ipv6_hdr(skb)->hop_limit;
put_cmsg(msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim);
}
if (np->rxopt.bits.ohopopts && opt->hop) {
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/esp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int esp6_input(struct xfrm_state *x, struct sk_buff *skb)
skb->ip_summed = CHECKSUM_NONE;

esph = (struct ipv6_esp_hdr*)skb->data;
iph = skb->nh.ipv6h;
iph = ipv6_hdr(skb);

/* Get ivec. This can be wrong, check against another impls. */
if (esp->conf.ivlen)
Expand Down
Loading

0 comments on commit 0660e03

Please sign in to comment.