[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
authorArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 21 Apr 2007 05:47:35 +0000 (22:47 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:25:10 +0000 (22:25 -0700)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
132 files changed:
drivers/ieee1394/eth1394.c
drivers/net/8139cp.c
drivers/net/atl1/atl1_main.c
drivers/net/bnx2.c
drivers/net/bonding/bond_alb.c
drivers/net/bonding/bond_main.c
drivers/net/chelsio/sge.c
drivers/net/cxgb3/sge.c
drivers/net/e1000/e1000_main.c
drivers/net/ehea/ehea_main.c
drivers/net/gianfar.c
drivers/net/ioc3-eth.c
drivers/net/ixgb/ixgb_main.c
drivers/net/loopback.c
drivers/net/mv643xx_eth.c
drivers/net/netxen/netxen_nic_hw.c
drivers/net/ns83820.c
drivers/net/pasemi_mac.c
drivers/net/r8169.c
drivers/net/sky2.c
drivers/net/spider_net.c
drivers/net/tg3.c
drivers/net/via-velocity.c
drivers/s390/net/qeth_main.c
drivers/s390/net/qeth_tso.h
include/linux/ip.h
include/linux/skbuff.h
include/net/inet_ecn.h
include/net/ip.h
include/net/pkt_cls.h
net/atm/mpc.c
net/bridge/br_netfilter.c
net/core/netpoll.c
net/core/pktgen.c
net/dccp/ipv4.c
net/econet/af_econet.c
net/ieee80211/ieee80211_tx.c
net/ipv4/af_inet.c
net/ipv4/ah4.c
net/ipv4/arp.c
net/ipv4/cipso_ipv4.c
net/ipv4/esp4.c
net/ipv4/icmp.c
net/ipv4/igmp.c
net/ipv4/ip_forward.c
net/ipv4/ip_fragment.c
net/ipv4/ip_gre.c
net/ipv4/ip_input.c
net/ipv4/ip_options.c
net/ipv4/ip_output.c
net/ipv4/ip_sockglue.c
net/ipv4/ipcomp.c
net/ipv4/ipconfig.c
net/ipv4/ipip.c
net/ipv4/ipmr.c
net/ipv4/ipvs/ip_vs_app.c
net/ipv4/ipvs/ip_vs_core.c
net/ipv4/ipvs/ip_vs_dh.c
net/ipv4/ipvs/ip_vs_ftp.c
net/ipv4/ipvs/ip_vs_lblc.c
net/ipv4/ipvs/ip_vs_lblcr.c
net/ipv4/ipvs/ip_vs_proto_tcp.c
net/ipv4/ipvs/ip_vs_proto_udp.c
net/ipv4/ipvs/ip_vs_sh.c
net/ipv4/ipvs/ip_vs_xmit.c
net/ipv4/netfilter.c
net/ipv4/netfilter/ip_conntrack_core.c
net/ipv4/netfilter/ip_conntrack_helper_h323.c
net/ipv4/netfilter/ip_conntrack_netbios_ns.c
net/ipv4/netfilter/ip_conntrack_proto_sctp.c
net/ipv4/netfilter/ip_conntrack_proto_tcp.c
net/ipv4/netfilter/ip_conntrack_proto_udp.c
net/ipv4/netfilter/ip_conntrack_standalone.c
net/ipv4/netfilter/ip_nat_helper.c
net/ipv4/netfilter/ip_nat_helper_h323.c
net/ipv4/netfilter/ip_nat_rule.c
net/ipv4/netfilter/ip_nat_snmp_basic.c
net/ipv4/netfilter/ip_nat_standalone.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv4/netfilter/ipt_ECN.c
net/ipv4/netfilter/ipt_NETMAP.c
net/ipv4/netfilter/ipt_REJECT.c
net/ipv4/netfilter/ipt_TOS.c
net/ipv4/netfilter/ipt_TTL.c
net/ipv4/netfilter/ipt_addrtype.c
net/ipv4/netfilter/ipt_ecn.c
net/ipv4/netfilter/ipt_iprange.c
net/ipv4/netfilter/ipt_recent.c
net/ipv4/netfilter/ipt_tos.c
net/ipv4/netfilter/ipt_ttl.c
net/ipv4/netfilter/iptable_mangle.c
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
net/ipv4/netfilter/nf_nat_h323.c
net/ipv4/netfilter/nf_nat_helper.c
net/ipv4/netfilter/nf_nat_rule.c
net/ipv4/netfilter/nf_nat_snmp_basic.c
net/ipv4/netfilter/nf_nat_standalone.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv4/tcp_ipv4.c
net/ipv4/udp.c
net/ipv4/xfrm4_input.c
net/ipv4/xfrm4_mode_beet.c
net/ipv4/xfrm4_mode_transport.c
net/ipv4/xfrm4_mode_tunnel.c
net/ipv4/xfrm4_output.c
net/ipv4/xfrm4_policy.c
net/ipv4/xfrm4_tunnel.c
net/ipv6/datagram.c
net/ipv6/ip6_tunnel.c
net/ipv6/sit.c
net/ipv6/udp.c
net/netfilter/nf_conntrack_netbios_ns.c
net/netfilter/xt_DSCP.c
net/netfilter/xt_TCPMSS.c
net/netfilter/xt_dscp.c
net/netfilter/xt_hashlimit.c
net/netfilter/xt_length.c
net/netfilter/xt_pkttype.c
net/rxrpc/connection.c
net/rxrpc/transport.c
net/sched/cls_rsvp.h
net/sched/sch_atm.c
net/sched/sch_dsmark.c
net/sched/sch_sfq.c
net/sctp/input.c
net/sctp/ipv6.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c
net/sctp/sm_statefuns.c

index db2346f4d2075ee956bce08e2bf17a48cf3a224c..a364003ba47f3218703e60152ddf8befa4d89842 100644 (file)
@@ -1668,7 +1668,7 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
        if (memcmp(eth->h_dest, dev->broadcast, ETH1394_ALEN) == 0 ||
            proto == htons(ETH_P_ARP) ||
            (proto == htons(ETH_P_IP) &&
-            IN_MULTICAST(ntohl(skb->nh.iph->daddr)))) {
+            IN_MULTICAST(ntohl(ip_hdr(skb)->daddr)))) {
                tx_type = ETH1394_GASP;
                dest_node = LOCAL_BUS | ALL_NODES;
                max_payload = priv->bc_maxpayload - ETHER1394_GASP_OVERHEAD;
index 2f704cb06e7be19e5d3540f4fd5fc2ac47c86ed1..e8c9f27817b08f9d36c60d6abacf4b6c800e85a1 100644 (file)
@@ -806,7 +806,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
                if (mss)
                        flags |= LargeSend | ((mss & MSSMask) << MSSShift);
                else if (skb->ip_summed == CHECKSUM_PARTIAL) {
-                       const struct iphdr *ip = skb->nh.iph;
+                       const struct iphdr *ip = ip_hdr(skb);
                        if (ip->protocol == IPPROTO_TCP)
                                flags |= IPCS | TCPCS;
                        else if (ip->protocol == IPPROTO_UDP)
@@ -825,7 +825,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
                u32 first_len, first_eor;
                dma_addr_t first_mapping;
                int frag, first_entry = entry;
-               const struct iphdr *ip = skb->nh.iph;
+               const struct iphdr *ip = ip_hdr(skb);
 
                /* We must give this initial chunk to the device last.
                 * Otherwise we could race with the device.
index 793a61b2140f4eeff6cc8269ba17fc6c39a2598d..d2be79a30f8abde7bd00f894da1f821238c7bc29 100644 (file)
@@ -1294,17 +1294,18 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
                }
 
                if (skb->protocol == ntohs(ETH_P_IP)) {
-                       skb->nh.iph->tot_len = 0;
-                       skb->nh.iph->check = 0;
-                       skb->h.th->check =
-                           ~csum_tcpudp_magic(skb->nh.iph->saddr,
-                                              skb->nh.iph->daddr, 0,
-                                              IPPROTO_TCP, 0);
+                       struct iphdr *iph = ip_hdr(skb);
+
+                       iph->tot_len = 0;
+                       iph->check = 0;
+                       skb->h.th->check = ~csum_tcpudp_magic(iph->saddr,
+                                                             iph->daddr, 0,
+                                                             IPPROTO_TCP, 0);
                        ipofst = skb_network_offset(skb);
                        if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */
                                tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;
 
-                       tso->tsopl |= (skb->nh.iph->ihl &
+                       tso->tsopl |= (iph->ihl &
                                CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT;
                        tso->tsopl |= ((skb->h.th->doff << 2) &
                                TSO_PARAM_TCPHDRLEN_MASK) << TSO_PARAM_TCPHDRLEN_SHIFT;
index b8091c55d441dfa070b45f8538c51b206b53de83..eb0c4f1d448313fea0db44ab62d2c85602f64d4e 100644 (file)
@@ -4513,6 +4513,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if ((mss = skb_shinfo(skb)->gso_size) &&
                (skb->len > (bp->dev->mtu + ETH_HLEN))) {
                u32 tcp_opt_len, ip_tcp_len;
+               struct iphdr *iph;
 
                if (skb_header_cloned(skb) &&
                    pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
@@ -4529,16 +4530,15 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
                }
                ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
 
-               skb->nh.iph->check = 0;
-               skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
-               skb->h.th->check =
-                       ~csum_tcpudp_magic(skb->nh.iph->saddr,
-                                           skb->nh.iph->daddr,
-                                           0, IPPROTO_TCP, 0);
+               iph = ip_hdr(skb);
+               iph->check = 0;
+               iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
+               skb->h.th->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
+                                                     0, IPPROTO_TCP, 0);
 
-               if (tcp_opt_len || (skb->nh.iph->ihl > 5)) {
-                       vlan_tag_flags |= ((skb->nh.iph->ihl - 5) +
-                               (tcp_opt_len >> 2)) << 8;
+               if (tcp_opt_len || (iph->ihl > 5)) {
+                       vlan_tag_flags |= ((iph->ihl - 5) +
+                                          (tcp_opt_len >> 2)) << 8;
                }
        }
        else
index 86cfcb3f8131989189df5cae53eea9a2357ad88f..8555afa574a4ee4562da58cdbc1f686895538b2d 100644 (file)
@@ -112,7 +112,7 @@ static inline struct arp_pkt *arp_pkt(const struct sk_buff *skb)
 /* Forward declaration */
 static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]);
 
-static inline u8 _simple_hash(u8 *hash_start, int hash_size)
+static inline u8 _simple_hash(const u8 *hash_start, int hash_size)
 {
        int i;
        u8 hash = 0;
@@ -1268,7 +1268,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
        int hash_size = 0;
        int do_tx_balance = 1;
        u32 hash_index = 0;
-       u8 *hash_start = NULL;
+       const u8 *hash_start = NULL;
        int res = 1;
 
        skb_reset_mac_header(skb);
@@ -1285,15 +1285,18 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
        }
 
        switch (ntohs(skb->protocol)) {
-       case ETH_P_IP:
+       case ETH_P_IP: {
+               const struct iphdr *iph = ip_hdr(skb);
+
                if ((memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) ||
-                   (skb->nh.iph->daddr == ip_bcast) ||
-                   (skb->nh.iph->protocol == IPPROTO_IGMP)) {
+                   (iph->daddr == ip_bcast) ||
+                   (iph->protocol == IPPROTO_IGMP)) {
                        do_tx_balance = 0;
                        break;
                }
-               hash_start = (char*)&(skb->nh.iph->daddr);
-               hash_size = sizeof(skb->nh.iph->daddr);
+               hash_start = (char *)&(iph->daddr);
+               hash_size = sizeof(iph->daddr);
+       }
                break;
        case ETH_P_IPV6:
                if (memcmp(eth_data->h_dest, mac_bcast, ETH_ALEN) == 0) {
index e4724d874e7c5cb5ee90acd72b6ebca2000bcbc3..7f11388893fc613dc9867d6173d62f1c131442bb 100644 (file)
@@ -3476,7 +3476,7 @@ static int bond_xmit_hash_policy_l34(struct sk_buff *skb,
                                    struct net_device *bond_dev, int count)
 {
        struct ethhdr *data = (struct ethhdr *)skb->data;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        u16 *layer4hdr = (u16 *)((u32 *)iph + iph->ihl);
        int layer4_xor = 0;
 
index 8cdee67d582f256aa58dbb815e24b7a99ee9c69a..c357f45a16c3f921225ff6c5d195242c50d23f60 100644 (file)
@@ -1871,7 +1871,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
                hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));
                hdr->opcode = CPL_TX_PKT_LSO;
                hdr->ip_csum_dis = hdr->l4_csum_dis = 0;
-               hdr->ip_hdr_words = skb->nh.iph->ihl;
+               hdr->ip_hdr_words = ip_hdr(skb)->ihl;
                hdr->tcp_hdr_words = skb->h.th->doff;
                hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
                                                          skb_shinfo(skb)->gso_size));
@@ -1912,7 +1912,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
                if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
                    skb->ip_summed == CHECKSUM_PARTIAL &&
-                   skb->nh.iph->protocol == IPPROTO_UDP) {
+                   ip_hdr(skb)->protocol == IPPROTO_UDP) {
                        if (unlikely(skb_checksum_help(skb))) {
                                pr_debug("%s: unable to do udp checksum\n", dev->name);
                                dev_kfree_skb_any(skb);
index 7e9e9db4fb978aa6b710e3ab41f3f9a8e2015585..892e5dcafa0453dd4a6d102daaf712f2b1e5181d 100644 (file)
@@ -900,7 +900,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
                eth_type = skb_network_offset(skb) == ETH_HLEN ?
                    CPL_ETH_II : CPL_ETH_II_VLAN;
                tso_info |= V_LSO_ETH_TYPE(eth_type) |
-                   V_LSO_IPHDR_WORDS(skb->nh.iph->ihl) |
+                   V_LSO_IPHDR_WORDS(ip_hdr(skb)->ihl) |
                    V_LSO_TCPHDR_WORDS(skb->h.th->doff);
                hdr->lso_info = htonl(tso_info);
                flits = 3;
index 86161011b53964b0c962e6ebc36013de9a08aca1..c324866c97893537abd456fc28eae9f2994ad2ee 100644 (file)
@@ -2890,14 +2890,12 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
                hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
                mss = skb_shinfo(skb)->gso_size;
                if (skb->protocol == htons(ETH_P_IP)) {
-                       skb->nh.iph->tot_len = 0;
-                       skb->nh.iph->check = 0;
-                       skb->h.th->check =
-                               ~csum_tcpudp_magic(skb->nh.iph->saddr,
-                                                  skb->nh.iph->daddr,
-                                                  0,
-                                                  IPPROTO_TCP,
-                                                  0);
+                       struct iphdr *iph = ip_hdr(skb);
+                       iph->tot_len = 0;
+                       iph->check = 0;
+                       skb->h.th->check = ~csum_tcpudp_magic(iph->saddr,
+                                                             iph->daddr, 0,
+                                                             IPPROTO_TCP, 0);
                        cmd_length = E1000_TXD_CMD_IP;
                        ipcse = skb->h.raw - skb->data - 1;
                } else if (skb->protocol == htons(ETH_P_IPV6)) {
@@ -2911,7 +2909,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
                        ipcse = 0;
                }
                ipcss = skb_network_offset(skb);
-               ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
+               ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
                tucss = skb->h.raw - skb->data;
                tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
                tucse = 0;
index b1c90a4fe31e04f14082e3567903a67f574773ba..0dc701e611e5a084afd9d4eab116c57a2ab41d3e 100644 (file)
@@ -1262,7 +1262,7 @@ static int ehea_clean_portres(struct ehea_port *port, struct ehea_port_res *pr)
 static inline void write_ip_start_end(struct ehea_swqe *swqe,
                                      const struct sk_buff *skb)
 {
-       swqe->ip_start = (u8)(((u64)skb->nh.iph) - ((u64)skb->data));
+       swqe->ip_start = skb_network_offset(skb);
        swqe->ip_end = (u8)(swqe->ip_start + ip_hdrlen(skb) - 1);
 }
 
@@ -1688,6 +1688,7 @@ static void ehea_xmit2(struct sk_buff *skb, struct net_device *dev,
                       struct ehea_swqe *swqe, u32 lkey)
 {
        if (skb->protocol == htons(ETH_P_IP)) {
+               const struct iphdr *iph = ip_hdr(skb);
                /* IPv4 */
                swqe->tx_control |= EHEA_SWQE_CRC
                                 | EHEA_SWQE_IP_CHECKSUM
@@ -1697,15 +1698,15 @@ static void ehea_xmit2(struct sk_buff *skb, struct net_device *dev,
 
                write_ip_start_end(swqe, skb);
 
-               if (skb->nh.iph->protocol == IPPROTO_UDP) {
-                       if ((skb->nh.iph->frag_off & IP_MF) ||
-                           (skb->nh.iph->frag_off & IP_OFFSET))
+               if (iph->protocol == IPPROTO_UDP) {
+                       if ((iph->frag_off & IP_MF) ||
+                           (iph->frag_off & IP_OFFSET))
                                /* IP fragment, so don't change cs */
                                swqe->tx_control &= ~EHEA_SWQE_TCP_CHECKSUM;
                        else
                                write_udp_offset_end(swqe, skb);
 
-               } else if (skb->nh.iph->protocol == IPPROTO_TCP) {
+               } else if (iph->protocol == IPPROTO_TCP) {
                        write_tcp_offset_end(swqe, skb);
                }
 
@@ -1731,10 +1732,11 @@ static void ehea_xmit3(struct sk_buff *skb, struct net_device *dev,
        int i;
 
        if (skb->protocol == htons(ETH_P_IP)) {
+               const struct iphdr *iph = ip_hdr(skb);
                /* IPv4 */
                write_ip_start_end(swqe, skb);
 
-               if (skb->nh.iph->protocol == IPPROTO_TCP) {
+               if (iph->protocol == IPPROTO_TCP) {
                        swqe->tx_control |= EHEA_SWQE_CRC
                                         | EHEA_SWQE_IP_CHECKSUM
                                         | EHEA_SWQE_TCP_CHECKSUM
@@ -1742,9 +1744,9 @@ static void ehea_xmit3(struct sk_buff *skb, struct net_device *dev,
 
                        write_tcp_offset_end(swqe, skb);
 
-               } else if (skb->nh.iph->protocol == IPPROTO_UDP) {
-                       if ((skb->nh.iph->frag_off & IP_MF) ||
-                           (skb->nh.iph->frag_off & IP_OFFSET))
+               } else if (iph->protocol == IPPROTO_UDP) {
+                       if ((iph->frag_off & IP_MF) ||
+                           (iph->frag_off & IP_OFFSET))
                                /* IP fragment, so don't change cs */
                                swqe->tx_control |= EHEA_SWQE_CRC
                                                 | EHEA_SWQE_IMM_DATA_PRESENT;
index c7a70933c7594df11d6ee86ca29cc840adc49bad..c9abc96a091926eb479327866444cb250ca03082 100644 (file)
@@ -942,7 +942,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
 
        /* Tell the controller what the protocol is */
        /* And provide the already calculated phcs */
-       if (skb->nh.iph->protocol == IPPROTO_UDP) {
+       if (ip_hdr(skb)->protocol == IPPROTO_UDP) {
                flags |= TXFCB_UDP;
                fcb->phcs = skb->h.uh->check;
        } else
index ea07aa5ba51b54394e742bf8ddd10a46fdfe432e..d375e786b4b3bc211a8a1b5cc7926d17feafb56e 100644 (file)
@@ -1393,9 +1393,9 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
         * manually.
         */
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               int proto = ntohs(skb->nh.iph->protocol);
+               const struct iphdr *ih = ip_hdr(skb);
+               const int proto = ntohs(ih->protocol);
                unsigned int csoff;
-               struct iphdr *ih = skb->nh.iph;
                uint32_t csum, ehsum;
                uint16_t *eh;
 
index cfb791bb45e29218693191e7657f60800daf429e..bba4dcaf92e9998cdc281a0e099e95fbeef2c82f 100644 (file)
@@ -1182,6 +1182,8 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
 
        if (likely(skb_is_gso(skb))) {
                struct ixgb_buffer *buffer_info;
+               struct iphdr *iph;
+
                if (skb_header_cloned(skb)) {
                        err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
                        if (err)
@@ -1190,13 +1192,13 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
 
                hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
                mss = skb_shinfo(skb)->gso_size;
-               skb->nh.iph->tot_len = 0;
-               skb->nh.iph->check = 0;
-               skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
-                                                     skb->nh.iph->daddr,
+               iph = ip_hdr(skb);
+               iph->tot_len = 0;
+               iph->check = 0;
+               skb->h.th->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
                                                      0, IPPROTO_TCP, 0);
                ipcss = skb_network_offset(skb);
-               ipcso = (void *)&(skb->nh.iph->check) - (void *)skb->data;
+               ipcso = (void *)&(iph->check) - (void *)skb->data;
                ipcse = skb->h.raw - skb->data - 1;
                tucss = skb->h.raw - skb->data;
                tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
index 9265c27b13b295d1754023175b2ed7b970a52e78..20b5cb1013681dcfccd863a9bf9eaac5f4668c4f 100644 (file)
@@ -75,7 +75,7 @@ static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats);
 #ifdef LOOPBACK_TSO
 static void emulate_large_send_offload(struct sk_buff *skb)
 {
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct tcphdr *th = (struct tcphdr *)(skb_network_header(skb) +
                                              (iph->ihl * 4));
        unsigned int doffset = (iph->ihl + th->doff) * 4;
@@ -93,7 +93,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
                skb_reserve(nskb, 32);
                skb_set_mac_header(nskb, -ETH_HLEN);
                skb_reset_network_header(nskb);
-               iph = nskb->nh.iph;
+               iph = ip_hdr(nskb);
                memcpy(nskb->data, skb_network_header(skb), doffset);
                if (skb_copy_bits(skb,
                                  doffset + offset,
@@ -145,7 +145,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
 #ifdef LOOPBACK_TSO
        if (skb_is_gso(skb)) {
                BUG_ON(skb->protocol != htons(ETH_P_IP));
-               BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
+               BUG_ON(ip_hdr(skb)->protocol != IPPROTO_TCP);
 
                emulate_large_send_offload(skb);
                return 0;
index cd9369a285e2ad10573d2893ae5c20372c552603..6b39a268ec29409ea0c6b378709ef078b4d84d7a 100644 (file)
@@ -1161,9 +1161,9 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
 
                cmd_sts |= ETH_GEN_TCP_UDP_CHECKSUM |
                           ETH_GEN_IP_V_4_CHECKSUM  |
-                          skb->nh.iph->ihl << ETH_TX_IHL_SHIFT;
+                          ip_hdr(skb)->ihl << ETH_TX_IHL_SHIFT;
 
-               switch (skb->nh.iph->protocol) {
+               switch (ip_hdr(skb)->protocol) {
                case IPPROTO_UDP:
                        cmd_sts |= ETH_UDP_FRAME;
                        desc->l4i_chk = skb->h.uh->check;
index b2f5032937e3376bcacb0c796e3ab3d96a355339..28d68c3550efe0722a512492fd944cc4bd260fdb 100644 (file)
@@ -378,9 +378,9 @@ void netxen_tso_check(struct netxen_adapter *adapter,
                                          skb->h.th->doff * 4);
                netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
        } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               if (skb->nh.iph->protocol == IPPROTO_TCP) {
+               if (ip_hdr(skb)->protocol == IPPROTO_TCP) {
                        netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT);
-               } else if (skb->nh.iph->protocol == IPPROTO_UDP) {
+               } else if (ip_hdr(skb)->protocol == IPPROTO_UDP) {
                        netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT);
                } else {
                        return;
index 747988b12ecda9f794a4b34ea82285f0f27991c8..6a32338623f18bdeacca68b2ffc9e771cf03bfeb 100644 (file)
@@ -1156,9 +1156,9 @@ again:
        extsts = 0;
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                extsts |= EXTSTS_IPPKT;
-               if (IPPROTO_TCP == skb->nh.iph->protocol)
+               if (IPPROTO_TCP == ip_hdr(skb)->protocol)
                        extsts |= EXTSTS_TCPPKT;
-               else if (IPPROTO_UDP == skb->nh.iph->protocol)
+               else if (IPPROTO_UDP == ip_hdr(skb)->protocol)
                        extsts |= EXTSTS_UDPPKT;
        }
 
index 82218720bc3ea599dec3502cf29bdd734486f575..1d8129986cc5722936539c805ccbc3d79740f355 100644 (file)
@@ -731,7 +731,7 @@ static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
                const unsigned char *nh = skb_network_header(skb);
 
-               switch (skb->nh.iph->protocol) {
+               switch (ip_hdr(skb)->protocol) {
                case IPPROTO_TCP:
                        dflags |= XCT_MACTX_CSUM_TCP;
                        dflags |= XCT_MACTX_IPH((skb->h.raw - skb->nh.raw) >> 2);
index 34280f94e9ff071e0bc7951cb08f814fac15af84..45876a854f002975893d95265798797bb4bc7f1d 100644 (file)
@@ -2284,7 +2284,7 @@ static inline u32 rtl8169_tso_csum(struct sk_buff *skb, struct net_device *dev)
                        return LargeSend | ((mss & MSSMask) << MSSShift);
        }
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               const struct iphdr *ip = skb->nh.iph;
+               const struct iphdr *ip = ip_hdr(skb);
 
                if (ip->protocol == IPPROTO_TCP)
                        return IPCS | TCPCS;
index 51e994f26a844ffeccc573c09f98354707300ebc..a37bb205f3d3076a4b0a253790577a7243a474ae 100644 (file)
@@ -1428,7 +1428,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
                tcpsum |= offset + skb->csum_offset;    /* sum write */
 
                ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
-               if (skb->nh.iph->protocol == IPPROTO_UDP)
+               if (ip_hdr(skb)->protocol == IPPROTO_UDP)
                        ctrl |= UDPTCP;
 
                if (tcpsum != sky2->tx_tcpsum) {
index f7e0ac7f789afcce6f1de017c91d0c174e3e8dd8..230da14b1b682f44c87fab30b52c2ad0033b5c51 100644 (file)
@@ -720,7 +720,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
        spin_unlock_irqrestore(&chain->lock, flags);
 
        if (skb->protocol == htons(ETH_P_IP) && skb->ip_summed == CHECKSUM_PARTIAL)
-               switch (skb->nh.iph->protocol) {
+               switch (ip_hdr(skb)->protocol) {
                case IPPROTO_TCP:
                        hwdescr->dmac_cmd_status |= SPIDER_NET_DMAC_TCP;
                        break;
index 62a3bba0097d8114ae980a5b3f49e02cb7605806..76a31afe20deefb922d1284328da089273b6dc65 100644 (file)
@@ -3909,12 +3909,13 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
                if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
                        mss |= (skb_headlen(skb) - ETH_HLEN) << 9;
                else {
+                       struct iphdr *iph = ip_hdr(skb);
+
                        tcp_opt_len = ((skb->h.th->doff - 5) * 4);
                        ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);
 
-                       skb->nh.iph->check = 0;
-                       skb->nh.iph->tot_len = htons(mss + ip_tcp_len +
-                                                    tcp_opt_len);
+                       iph->check = 0;
+                       iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
                        mss |= (ip_tcp_len + tcp_opt_len) << 9;
                }
 
@@ -4055,6 +4056,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
        mss = 0;
        if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
            (mss = skb_shinfo(skb)->gso_size) != 0) {
+               struct iphdr *iph;
                int tcp_opt_len, ip_tcp_len, hdr_len;
 
                if (skb_header_cloned(skb) &&
@@ -4074,34 +4076,32 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
                base_flags |= (TXD_FLAG_CPU_PRE_DMA |
                               TXD_FLAG_CPU_POST_DMA);
 
-               skb->nh.iph->check = 0;
-               skb->nh.iph->tot_len = htons(mss + hdr_len);
+               iph = ip_hdr(skb);
+               iph->check = 0;
+               iph->tot_len = htons(mss + hdr_len);
                if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
                        skb->h.th->check = 0;
                        base_flags &= ~TXD_FLAG_TCPUDP_CSUM;
                }
                else {
-                       skb->h.th->check =
-                               ~csum_tcpudp_magic(skb->nh.iph->saddr,
-                                                  skb->nh.iph->daddr,
-                                                  0, IPPROTO_TCP, 0);
+                       skb->h.th->check = ~csum_tcpudp_magic(iph->saddr,
+                                                             iph->daddr, 0,
+                                                             IPPROTO_TCP, 0);
                }
 
                if ((tp->tg3_flags2 & TG3_FLG2_HW_TSO) ||
                    (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) {
-                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
+                       if (tcp_opt_len || iph->ihl > 5) {
                                int tsflags;
 
-                               tsflags = ((skb->nh.iph->ihl - 5) +
-                                          (tcp_opt_len >> 2));
+                               tsflags = (iph->ihl - 5) + (tcp_opt_len >> 2);
                                mss |= (tsflags << 11);
                        }
                } else {
-                       if (tcp_opt_len || skb->nh.iph->ihl > 5) {
+                       if (tcp_opt_len || iph->ihl > 5) {
                                int tsflags;
 
-                               tsflags = ((skb->nh.iph->ihl - 5) +
-                                          (tcp_opt_len >> 2));
+                               tsflags = (iph->ihl - 5) + (tcp_opt_len >> 2);
                                base_flags |= tsflags << 12;
                        }
                }
index 9f6cc1569b3ed2f210c0d785667f77d1dfca4ea6..422eaf8ea12d80851200425f8c2bdcb626657d56 100644 (file)
@@ -2006,7 +2006,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
         */
        if ((vptr->flags & VELOCITY_FLAGS_TX_CSUM)
                                 && (skb->ip_summed == CHECKSUM_PARTIAL)) {
-               struct iphdr *ip = skb->nh.iph;
+               const struct iphdr *ip = ip_hdr(skb);
                if (ip->protocol == IPPROTO_TCP)
                        td_ptr->tdesc1.TCR |= TCR0_TCPCK;
                else if (ip->protocol == IPPROTO_UDP)
index 0ff29e0628b5429c56e66276c456e4c3f08d303f..8a07d548a05a1d35514a96432c7aa02e5ba5de25 100644 (file)
@@ -3820,18 +3820,20 @@ qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb,
                        return card->info.is_multicast_different &
                                (card->qdio.no_out_queues - 1);
                if (card->qdio.do_prio_queueing && (ipv == 4)) {
+                       const u8 tos = ip_hdr(skb)->tos;
+
                        if (card->qdio.do_prio_queueing==QETH_PRIO_Q_ING_TOS){
-                               if (skb->nh.iph->tos & IP_TOS_NOTIMPORTANT)
+                               if (tos & IP_TOS_NOTIMPORTANT)
                                        return 3;
-                               if (skb->nh.iph->tos & IP_TOS_HIGHRELIABILITY)
+                               if (tos & IP_TOS_HIGHRELIABILITY)
                                        return 2;
-                               if (skb->nh.iph->tos & IP_TOS_HIGHTHROUGHPUT)
+                               if (tos & IP_TOS_HIGHTHROUGHPUT)
                                        return 1;
-                               if (skb->nh.iph->tos & IP_TOS_LOWDELAY)
+                               if (tos & IP_TOS_LOWDELAY)
                                        return 0;
                        }
                        if (card->qdio.do_prio_queueing==QETH_PRIO_Q_ING_PREC)
-                               return 3 - (skb->nh.iph->tos >> 6);
+                               return 3 - (tos >> 6);
                } else if (card->qdio.do_prio_queueing && (ipv == 6)) {
                        /* TODO: IPv6!!! */
                }
@@ -4041,7 +4043,8 @@ qeth_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
                            *((u32 *) skb->dst->neighbour->primary_key);
                } else {
                        /* fill in destination address used in ip header */
-                       *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = skb->nh.iph->daddr;
+                       *((u32 *)(&hdr->hdr.l3.dest_addr[12])) =
+                                                          ip_hdr(skb)->daddr;
                }
        } else if (ipv == 6) { /* IPv6 or passthru */
                hdr->hdr.l3.flags = qeth_get_qeth_hdr_flags6(cast_type);
index 14504afb044e6858f01acf3da7a6e6a5a8a6d547..255cb2e9c7965f40ca1042167459301d43923c96 100644 (file)
@@ -40,7 +40,7 @@ qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
        QETH_DBF_TEXT(trace, 5, "tsofhdr");
 
        hdr  = (struct qeth_hdr_tso *) skb->data;
-       iph  = skb->nh.iph;
+       iph  = ip_hdr(skb);
        tcph = skb->h.th;
        /*fix header to TSO values ...*/
        hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
@@ -63,13 +63,9 @@ qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)
 static inline void
 qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
 {
-       struct iphdr *iph;
-       struct ipv6hdr *ip6h;
-       struct tcphdr *tcph;
-
-       iph  = skb->nh.iph;
-       ip6h = skb->nh.ipv6h;
-       tcph = skb->h.th;
+       struct iphdr *iph    = ip_hdr(skb);
+       struct ipv6hdr *ip6h = skb->nh.ipv6h;
+       struct tcphdr *tcph  = skb->h.th;
 
        tcph->check = 0;
        if (skb->protocol == ETH_P_IPV6) {
index 1d36b971a8b53b869b4588fca445382aec25a09a..f2f26db16f5718d6762b4be31c353c5e376485d3 100644 (file)
@@ -104,6 +104,15 @@ struct iphdr {
        /*The options start here. */
 };
 
+#ifdef __KERNEL__
+#include <linux/skbuff.h>
+
+static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
+{
+       return (struct iphdr *)skb_network_header(skb);
+}
+#endif
+
 struct ip_auth_hdr {
        __u8  nexthdr;
        __u8  hdrlen;           /* This one is measured in 32 bit units! */
index 870438fba93fae2be33dabc347da20ea591730ee..62f841b5b70020a39ceb9bcce08ac9d2460d66ac 100644 (file)
@@ -247,7 +247,6 @@ struct sk_buff {
        } h;
 
        union {
-               struct iphdr    *iph;
                struct ipv6hdr  *ipv6h;
                struct arphdr   *arph;
                unsigned char   *raw;
index b9ed3898e368b5963b5d9a9106f4b1a6678ea9e3..6fd4452c15d95c0b9d84bc033150183e9108801c 100644 (file)
@@ -116,7 +116,7 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
        case __constant_htons(ETH_P_IP):
                if (skb_network_header(skb) + sizeof(struct iphdr) <=
                    skb->tail)
-                       return IP_ECN_set_ce(skb->nh.iph);
+                       return IP_ECN_set_ce(ip_hdr(skb));
                break;
 
        case __constant_htons(ETH_P_IPV6):
index 6f7ba32b199dc38770f27f28dc6c08fe2785f7a8..75f226d26e0d2ea550fef199b0f2626bd71d5381 100644 (file)
@@ -46,7 +46,7 @@ struct inet_skb_parm
 
 static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
 {
-       return skb->nh.iph->ihl * 4;
+       return ip_hdr(skb)->ihl * 4;
 }
 
 struct ipcm_cookie
index 8a6b0e7bded565ca0ab9119b5193bc8d2f8dc071..880eb7b541643880a0870017948162d4212a9fa1 100644 (file)
@@ -334,8 +334,8 @@ static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer)
        return NULL;
 }
 
-static inline int tcf_valid_offset(struct sk_buff *skb, unsigned char *ptr,
-                                  int len)
+static inline int tcf_valid_offset(const struct sk_buff *skb,
+                                  const unsigned char *ptr, const int len)
 {
        return unlikely((ptr + len) < skb->tail && ptr > skb->head);
 }
index bc15728fd84772259794333a4598047f0d5379c4..4d2592c140905fc849250f1bd050030f76c6284f 100644 (file)
@@ -715,7 +715,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
        new_skb->protocol = eth_type_trans(new_skb, dev);
        skb_reset_network_header(new_skb);
 
-       eg->latest_ip_addr = new_skb->nh.iph->saddr;
+       eg->latest_ip_addr = ip_hdr(new_skb)->saddr;
        eg->packets_rcvd++;
        mpc->eg_ops->put(eg);
 
index 8a56d89630252a255db6e6919486c73788196eca..ebe740f6b902b3e378fe89cd7e5397471239e718 100644 (file)
@@ -48,8 +48,8 @@
 
 #define skb_origaddr(skb)       (((struct bridge_skb_cb *) \
                                 (skb->nf_bridge->data))->daddr.ipv4)
-#define store_orig_dstaddr(skb)         (skb_origaddr(skb) = (skb)->nh.iph->daddr)
-#define dnat_took_place(skb)    (skb_origaddr(skb) != (skb)->nh.iph->daddr)
+#define store_orig_dstaddr(skb)         (skb_origaddr(skb) = ip_hdr(skb)->daddr)
+#define dnat_took_place(skb)    (skb_origaddr(skb) != ip_hdr(skb)->daddr)
 
 #ifdef CONFIG_SYSCTL
 static struct ctl_table_header *brnf_sysctl_header;
@@ -265,7 +265,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
 static int br_nf_pre_routing_finish(struct sk_buff *skb)
 {
        struct net_device *dev = skb->dev;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct nf_bridge_info *nf_bridge = skb->nf_bridge;
        int err;
 
@@ -520,14 +520,14 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb,
        if (!pskb_may_pull(skb, sizeof(struct iphdr)))
                goto inhdr_error;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (iph->ihl < 5 || iph->version != 4)
                goto inhdr_error;
 
        if (!pskb_may_pull(skb, 4 * iph->ihl))
                goto inhdr_error;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (ip_fast_csum((__u8 *) iph, iph->ihl) != 0)
                goto inhdr_error;
 
index 44e030eb6e75f7029d655d31f6a9b321069d9f0d..c4cec17be334478a52a5942ec1021449fd0bafef 100644 (file)
@@ -310,7 +310,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
 
        skb_push(skb, sizeof(*iph));
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        /* iph->version = 4; iph->ihl = 5; */
        put_unaligned(0x45, (unsigned char *)iph);
index 10d33fc233b3a2de073b83e839ea128c82bc97ff..e0faff8eb652f0c5108315ec03f19705750740eb 100644 (file)
@@ -2391,7 +2391,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
                VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev);
        skb->dev = odev;
        skb->pkt_type = PACKET_HOST;
-       skb->nh.iph = iph;
+       skb->nh.raw = (unsigned char *)iph;
        skb->h.uh = udph;
 
        if (pkt_dev->nfrags <= 0)
index 4a83978aa660dd9a628bb9134af6bd853de1353d..b85437dae0e7595cb1e125320e53a54938ae696e 100644 (file)
@@ -363,8 +363,8 @@ EXPORT_SYMBOL_GPL(dccp_v4_send_check);
 
 static inline u64 dccp_v4_init_sequence(const struct sk_buff *skb)
 {
-       return secure_dccp_sequence_number(skb->nh.iph->daddr,
-                                          skb->nh.iph->saddr,
+       return secure_dccp_sequence_number(ip_hdr(skb)->daddr,
+                                          ip_hdr(skb)->saddr,
                                           dccp_hdr(skb)->dccph_dport,
                                           dccp_hdr(skb)->dccph_sport);
 }
@@ -405,7 +405,7 @@ struct sock *dccp_v4_request_recv_sock(struct sock *sk, struct sk_buff *skb,
        newinet->opt       = ireq->opt;
        ireq->opt          = NULL;
        newinet->mc_index  = inet_iif(skb);
-       newinet->mc_ttl    = skb->nh.iph->ttl;
+       newinet->mc_ttl    = ip_hdr(skb)->ttl;
        newinet->id        = jiffies;
 
        dccp_sync_mss(newsk, dst_mtu(dst));
@@ -428,7 +428,7 @@ EXPORT_SYMBOL_GPL(dccp_v4_request_recv_sock);
 static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
 {
        const struct dccp_hdr *dh = dccp_hdr(skb);
-       const struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
        struct sock *nsk;
        struct request_sock **prev;
        /* Find possible connection requests. */
@@ -460,8 +460,8 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
        struct rtable *rt;
        struct flowi fl = { .oif = ((struct rtable *)skb->dst)->rt_iif,
                            .nl_u = { .ip4_u =
-                                     { .daddr = skb->nh.iph->saddr,
-                                       .saddr = skb->nh.iph->daddr,
+                                     { .daddr = ip_hdr(skb)->saddr,
+                                       .saddr = ip_hdr(skb)->daddr,
                                        .tos = RT_CONN_FLAGS(sk) } },
                            .proto = sk->sk_protocol,
                            .uli_u = { .ports =
@@ -513,6 +513,7 @@ static void dccp_v4_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
 {
        int err;
        struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
+       const struct iphdr *rxiph;
        const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
                                       sizeof(struct dccp_hdr_ext) +
                                       sizeof(struct dccp_hdr_reset);
@@ -559,13 +560,13 @@ static void dccp_v4_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_v4_csum_finish(skb, rxskb->nh.iph->saddr,
-                                                     rxskb->nh.iph->daddr);
+       rxiph = ip_hdr(rxskb);
+       dh->dccph_checksum = dccp_v4_csum_finish(skb, rxiph->saddr,
+                                                rxiph->daddr);
 
        bh_lock_sock(dccp_v4_ctl_socket->sk);
        err = ip_build_and_send_pkt(skb, dccp_v4_ctl_socket->sk,
-                                   rxskb->nh.iph->daddr,
-                                   rxskb->nh.iph->saddr, NULL);
+                                   rxiph->daddr, rxiph->saddr, NULL);
        bh_unlock_sock(dccp_v4_ctl_socket->sk);
 
        if (net_xmit_eval(err) == 0) {
@@ -640,8 +641,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
                goto drop_and_free;
 
        ireq = inet_rsk(req);
-       ireq->loc_addr = skb->nh.iph->daddr;
-       ireq->rmt_addr = skb->nh.iph->saddr;
+       ireq->loc_addr = ip_hdr(skb)->daddr;
+       ireq->rmt_addr = ip_hdr(skb)->saddr;
        ireq->opt       = NULL;
 
        /*
@@ -809,6 +810,7 @@ EXPORT_SYMBOL_GPL(dccp_invalid_packet);
 static int dccp_v4_rcv(struct sk_buff *skb)
 {
        const struct dccp_hdr *dh;
+       const struct iphdr *iph;
        struct sock *sk;
        int min_cov;
 
@@ -817,8 +819,9 @@ static int dccp_v4_rcv(struct sk_buff *skb)
        if (dccp_invalid_packet(skb))
                goto discard_it;
 
+       iph = ip_hdr(skb);
        /* Step 1: If header checksum is incorrect, drop packet and return */
-       if (dccp_v4_csum_finish(skb, skb->nh.iph->saddr, skb->nh.iph->daddr)) {
+       if (dccp_v4_csum_finish(skb, iph->saddr, iph->daddr)) {
                DCCP_WARN("dropped packet with invalid checksum\n");
                goto discard_it;
        }
@@ -832,8 +835,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
                      "src=%u.%u.%u.%u@%-5d "
                      "dst=%u.%u.%u.%u@%-5d seq=%llu",
                      dccp_packet_name(dh->dccph_type),
-                     NIPQUAD(skb->nh.iph->saddr), ntohs(dh->dccph_sport),
-                     NIPQUAD(skb->nh.iph->daddr), ntohs(dh->dccph_dport),
+                     NIPQUAD(iph->saddr), ntohs(dh->dccph_sport),
+                     NIPQUAD(iph->daddr), ntohs(dh->dccph_dport),
                      (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
 
        if (dccp_packet_without_ack(skb)) {
@@ -848,10 +851,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
        /* Step 2:
         *      Look up flow ID in table and get corresponding socket */
        sk = __inet_lookup(&dccp_hashinfo,
-                          skb->nh.iph->saddr, dh->dccph_sport,
-                          skb->nh.iph->daddr, dh->dccph_dport,
-                          inet_iif(skb));
-
+                          iph->saddr, dh->dccph_sport,
+                          iph->daddr, dh->dccph_dport, inet_iif(skb));
        /*
         * Step 2:
         *      If no socket ...
index 099543f5401f5edc3f813bf2f40b02b682026324..dcc2e4b6b2fed3f463413d4bb9d796c39b379999 100644 (file)
@@ -848,7 +848,7 @@ static void aun_send_response(__u32 addr, unsigned long seq, int code, int cb)
 
 static void aun_incoming(struct sk_buff *skb, struct aunhdr *ah, size_t len)
 {
-       struct iphdr *ip = skb->nh.iph;
+       struct iphdr *ip = ip_hdr(skb);
        unsigned char stn = ntohl(ip->saddr) & 0xff;
        struct sock *sk;
        struct sk_buff *newskb;
@@ -946,7 +946,7 @@ static void aun_data_available(struct sock *sk, int slen)
        data = skb->h.raw + sizeof(struct udphdr);
        ah = (struct aunhdr *)data;
        len = skb->len - sizeof(struct udphdr);
-       ip = skb->nh.iph;
+       ip = ip_hdr(skb);
 
        switch (ah->code)
        {
index 3fca4345ebe523ccb1a2b0ec57a5c7a987f0824d..62a8a2b76539895cc12e4f9283aa458d187c5a7a 100644 (file)
@@ -228,7 +228,7 @@ static int ieee80211_classify(struct sk_buff *skb)
        if (eth->h_proto != htons(ETH_P_IP))
                return 0;
 
-       ip = skb->nh.iph;
+       ip = ip_hdr(skb);
        switch (ip->tos & 0xfc) {
        case 0x20:
                return 2;
index ab552a6098f96e30d76c0ea0e452120e013c6a28..e7720c72a6e23792c4cf9c90ed4cc665b1297a1d 100644 (file)
@@ -1112,7 +1112,7 @@ static int inet_gso_send_check(struct sk_buff *skb)
        if (unlikely(!pskb_may_pull(skb, sizeof(*iph))))
                goto out;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        ihl = iph->ihl * 4;
        if (ihl < sizeof(*iph))
                goto out;
@@ -1121,7 +1121,7 @@ static int inet_gso_send_check(struct sk_buff *skb)
                goto out;
 
        skb->h.raw = __skb_pull(skb, ihl);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        proto = iph->protocol & (MAX_INET_PROTOS - 1);
        err = -EPROTONOSUPPORT;
 
@@ -1155,7 +1155,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
        if (unlikely(!pskb_may_pull(skb, sizeof(*iph))))
                goto out;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        ihl = iph->ihl * 4;
        if (ihl < sizeof(*iph))
                goto out;
@@ -1164,7 +1164,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
                goto out;
 
        skb->h.raw = __skb_pull(skb, ihl);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        id = ntohs(iph->id);
        proto = iph->protocol & (MAX_INET_PROTOS - 1);
        segs = ERR_PTR(-EPROTONOSUPPORT);
@@ -1180,7 +1180,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
 
        skb = segs;
        do {
-               iph = skb->nh.iph;
+               iph = ip_hdr(skb);
                iph->id = htons(id++);
                iph->tot_len = htons(skb->len - skb->mac_len);
                iph->check = 0;
index 95ddbbd1552a6916d3eb3249f3088ddb8e62fbef..00fd31da252ecda5f8595a21568aba4a03fd61d9 100644 (file)
@@ -65,7 +65,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
                char            buf[60];
        } tmp_iph;
 
-       top_iph = skb->nh.iph;
+       top_iph = ip_hdr(skb);
        iph = &tmp_iph.iph;
 
        iph->tos = top_iph->tos;
@@ -152,7 +152,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
        skb->ip_summed = CHECKSUM_NONE;
 
        ah = (struct ip_auth_hdr*)skb->data;
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        ihl = skb->data - skb_network_header(skb);
        memcpy(work_buf, iph, ihl);
index fd36eebbd90aff71a8f653cb5dd9b405301b4311..01d0e8dd17d86213131d363d92ee064e16c9f017 100644 (file)
@@ -342,13 +342,13 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
        switch (IN_DEV_ARP_ANNOUNCE(in_dev)) {
        default:
        case 0:         /* By default announce any local IP */
-               if (skb && inet_addr_type(skb->nh.iph->saddr) == RTN_LOCAL)
-                       saddr = skb->nh.iph->saddr;
+               if (skb && inet_addr_type(ip_hdr(skb)->saddr) == RTN_LOCAL)
+                       saddr = ip_hdr(skb)->saddr;
                break;
        case 1:         /* Restrict announcements of saddr in same subnet */
                if (!skb)
                        break;
-               saddr = skb->nh.iph->saddr;
+               saddr = ip_hdr(skb)->saddr;
                if (inet_addr_type(saddr) == RTN_LOCAL) {
                        /* saddr should be known to target */
                        if (inet_addr_onlink(in_dev, target, saddr))
index b0182aa2c81a9cf61d4a8edd73f8461c0059fa15..11a3404d65af2eef33a9ebf216fd3bb25425d694 100644 (file)
@@ -1676,7 +1676,7 @@ validate_return:
  */
 void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway)
 {
-       if (skb->nh.iph->protocol == IPPROTO_ICMP || error != -EACCES)
+       if (ip_hdr(skb)->protocol == IPPROTO_ICMP || error != -EACCES)
                return;
 
        if (gateway)
index 222d21e5bbeb10afb41609f98c0943990b4af7b2..ed3deed66445b4fc6c1ebc5cc5600d063aa5e472 100644 (file)
@@ -58,7 +58,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
        pskb_put(skb, trailer, clen - skb->len);
 
        __skb_push(skb, skb->data - skb_network_header(skb));
-       top_iph = skb->nh.iph;
+       top_iph = ip_hdr(skb);
        esph = (struct ip_esp_hdr *)(skb_network_header(skb) +
                                     top_iph->ihl * 4);
        top_iph->tot_len = htons(skb->len + alen);
@@ -218,7 +218,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb)
 
        /* ... check padding bits here. Silly. :-) */
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        ihl = iph->ihl * 4;
 
        if (x->encap) {
index ff124d40c585086af463180cc302e5bdb684e609..4d70c21c50aaf70a174a7dfc2dd58d73d5d2f395 100644 (file)
@@ -392,7 +392,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
        icmp_param->data.icmph.checksum = 0;
        icmp_out_count(icmp_param->data.icmph.type);
 
-       inet->tos = skb->nh.iph->tos;
+       inet->tos = ip_hdr(skb)->tos;
        daddr = ipc.addr = rt->rt_src;
        ipc.opt = NULL;
        if (icmp_param->replyopts.optlen) {
@@ -404,7 +404,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
                struct flowi fl = { .nl_u = { .ip4_u =
                                              { .daddr = daddr,
                                                .saddr = rt->rt_spec_dst,
-                                               .tos = RT_TOS(skb->nh.iph->tos) } },
+                                               .tos = RT_TOS(ip_hdr(skb)->tos) } },
                                    .proto = IPPROTO_ICMP };
                security_skb_classify_flow(skb, &fl);
                if (ip_route_output_key(&rt, &fl))
@@ -448,7 +448,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
         *      Check this, icmp_send is called from the most obscure devices
         *      sometimes.
         */
-       iph = skb_in->nh.iph;
+       iph = ip_hdr(skb_in);
 
        if ((u8 *)iph < skb_in->head || (u8 *)(iph + 1) > skb_in->tail)
                goto out;
@@ -676,7 +676,7 @@ static void icmp_unreach(struct sk_buff *skb)
                        printk(KERN_WARNING "%u.%u.%u.%u sent an invalid ICMP "
                                            "type %u, code %u "
                                            "error to a broadcast: %u.%u.%u.%u on %s\n",
-                              NIPQUAD(skb->nh.iph->saddr),
+                              NIPQUAD(ip_hdr(skb)->saddr),
                               icmph->type, icmph->code,
                               NIPQUAD(iph->daddr),
                               skb->dev->name);
@@ -751,7 +751,7 @@ static void icmp_redirect(struct sk_buff *skb)
                 */
        case ICMP_REDIR_HOST:
        case ICMP_REDIR_HOSTTOS:
-               ip_rt_redirect(skb->nh.iph->saddr, iph->daddr,
+               ip_rt_redirect(ip_hdr(skb)->saddr, iph->daddr,
                               skb->h.icmph->un.gateway,
                               iph->saddr, skb->dev);
                break;
index 0687a7235a6c7a2359eb08bf40eff44117f9e277..f511d03e24392c3cebca3893161460126acb2009 100644 (file)
@@ -315,7 +315,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
        skb_reserve(skb, LL_RESERVED_SPACE(dev));
 
        skb_reset_network_header(skb);
-       pip = skb->nh.iph;
+       pip = ip_hdr(skb);
        skb_put(skb, sizeof(struct iphdr) + 4);
 
        pip->version  = 4;
@@ -345,16 +345,14 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
 
 static int igmpv3_sendpack(struct sk_buff *skb)
 {
-       struct iphdr *pip = skb->nh.iph;
+       struct iphdr *pip = ip_hdr(skb);
        struct igmphdr *pig = skb->h.igmph;
-       int iplen, igmplen;
+       const int iplen = skb->tail - skb->nh.raw;
+       const int igmplen = skb->tail - skb->h.raw;
 
-       iplen = skb->tail - (unsigned char *)skb->nh.iph;
        pip->tot_len = htons(iplen);
        ip_send_check(pip);
-
-       igmplen = skb->tail - (unsigned char *)skb->h.igmph;
-       pig->csum = ip_compute_csum((void *)skb->h.igmph, igmplen);
+       pig->csum = ip_compute_csum(skb->h.igmph, igmplen);
 
        return NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dev,
                       dst_output);
@@ -667,7 +665,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
        skb_reserve(skb, LL_RESERVED_SPACE(dev));
 
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        skb_put(skb, sizeof(struct iphdr) + 4);
 
        iph->version  = 4;
index 369e721c4bab3cf0fd58e61b88f170ad891373cb..467ebedb99ba70680fa8f217e405ae48d9fe93e1 100644 (file)
@@ -74,7 +74,7 @@ int ip_forward(struct sk_buff *skb)
         *      that reaches zero, we must reply an ICMP control message telling
         *      that the packet's lifetime expired.
         */
-       if (skb->nh.iph->ttl <= 1)
+       if (ip_hdr(skb)->ttl <= 1)
                goto too_many_hops;
 
        if (!xfrm4_route_forward(skb))
@@ -88,7 +88,7 @@ int ip_forward(struct sk_buff *skb)
        /* We are about to mangle packet. Copy it! */
        if (skb_cow(skb, LL_RESERVED_SPACE(rt->u.dst.dev)+rt->u.dst.header_len))
                goto drop;
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        /* Decrease ttl after skb cow done */
        ip_decrease_ttl(iph);
index af120b2d5331f9cd8284a67f07aaf0a12fce356f..0231bdcb2ab7620b55c1aaeda45d256c5a0de2ef 100644 (file)
@@ -479,7 +479,7 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
                goto err;
        }
 
-       offset = ntohs(skb->nh.iph->frag_off);
+       offset = ntohs(ip_hdr(skb)->frag_off);
        flags = offset & ~IP_OFFSET;
        offset &= IP_OFFSET;
        offset <<= 3;           /* offset is in 8-byte chunks */
@@ -676,7 +676,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
        head->dev = dev;
        head->tstamp = qp->stamp;
 
-       iph = head->nh.iph;
+       iph = ip_hdr(head);
        iph->frag_off = 0;
        iph->tot_len = htons(len);
        IP_INC_STATS_BH(IPSTATS_MIB_REASMOKS);
@@ -700,7 +700,6 @@ out_fail:
 /* Process an incoming IP datagram fragment. */
 struct sk_buff *ip_defrag(struct sk_buff *skb, u32 user)
 {
-       struct iphdr *iph = skb->nh.iph;
        struct ipq *qp;
        struct net_device *dev;
 
@@ -713,7 +712,7 @@ struct sk_buff *ip_defrag(struct sk_buff *skb, u32 user)
        dev = skb->dev;
 
        /* Lookup (or create) queue header */
-       if ((qp = ip_find(iph, user)) != NULL) {
+       if ((qp = ip_find(ip_hdr(skb), user)) != NULL) {
                struct sk_buff *ret = NULL;
 
                spin_lock(&qp->lock);
index 7c6fda6fe8463d2f9470b98a5102620d33907eab..851f46b910f2c7904432f1ec85d1a378b2349c9b 100644 (file)
@@ -533,7 +533,7 @@ static inline void ipgre_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
 {
        if (INET_ECN_is_ce(iph->tos)) {
                if (skb->protocol == htons(ETH_P_IP)) {
-                       IP_ECN_set_ce(skb->nh.iph);
+                       IP_ECN_set_ce(ip_hdr(skb));
                } else if (skb->protocol == htons(ETH_P_IPV6)) {
                        IP6_ECN_set_ce(skb->nh.ipv6h);
                }
@@ -565,7 +565,7 @@ static int ipgre_rcv(struct sk_buff *skb)
        if (!pskb_may_pull(skb, 16))
                goto drop_nolock;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        h = skb->data;
        flags = *(__be16*)h;
 
@@ -670,7 +670,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
        struct net_device_stats *stats = &tunnel->stat;
-       struct iphdr  *old_iph = skb->nh.iph;
+       struct iphdr  *old_iph = ip_hdr(skb);
        struct iphdr  *tiph;
        u8     tos;
        __be16 df;
@@ -825,7 +825,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                        skb_set_owner_w(new_skb, skb->sk);
                dev_kfree_skb(skb);
                skb = new_skb;
-               old_iph = skb->nh.iph;
+               old_iph = ip_hdr(skb);
        }
 
        skb->h.raw = skb->nh.raw;
@@ -841,7 +841,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
         *      Push down and install the IPIP header.
         */
 
-       iph                     =       skb->nh.iph;
+       iph                     =       ip_hdr(skb);
        iph->version            =       4;
        iph->ihl                =       sizeof(struct iphdr) >> 2;
        iph->frag_off           =       df;
index 2ee132b330fd62e84b49c9e0544aea908553daa1..237880a804321cbe8d90c2263ec9bd2a524f732e 100644 (file)
@@ -158,7 +158,7 @@ DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics) __read_mostly;
 int ip_call_ra_chain(struct sk_buff *skb)
 {
        struct ip_ra_chain *ra;
-       u8 protocol = skb->nh.iph->protocol;
+       u8 protocol = ip_hdr(skb)->protocol;
        struct sock *last = NULL;
 
        read_lock(&ip_ra_lock);
@@ -171,7 +171,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
                if (sk && inet_sk(sk)->num == protocol &&
                    (!sk->sk_bound_dev_if ||
                     sk->sk_bound_dev_if == skb->dev->ifindex)) {
-                       if (skb->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
+                       if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
                                skb = ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN);
                                if (skb == NULL) {
                                        read_unlock(&ip_ra_lock);
@@ -206,7 +206,7 @@ static inline int ip_local_deliver_finish(struct sk_buff *skb)
        rcu_read_lock();
        {
                /* Note: See raw.c and net/raw.h, RAWV4_HTABLE_SIZE==MAX_INET_PROTOS */
-               int protocol = skb->nh.iph->protocol;
+               int protocol = ip_hdr(skb)->protocol;
                int hash;
                struct sock *raw_sk;
                struct net_protocol *ipprot;
@@ -218,7 +218,7 @@ static inline int ip_local_deliver_finish(struct sk_buff *skb)
                /* If there maybe a raw socket we must check - if not we
                 * don't care less
                 */
-               if (raw_sk && !raw_v4_input(skb, skb->nh.iph, hash))
+               if (raw_sk && !raw_v4_input(skb, ip_hdr(skb), hash))
                        raw_sk = NULL;
 
                if ((ipprot = rcu_dereference(inet_protos[hash])) != NULL) {
@@ -264,7 +264,7 @@ int ip_local_deliver(struct sk_buff *skb)
         *      Reassemble IP fragments.
         */
 
-       if (skb->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
+       if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
                skb = ip_defrag(skb, IP_DEFRAG_LOCAL_DELIVER);
                if (!skb)
                        return 0;
@@ -292,7 +292,7 @@ static inline int ip_rcv_options(struct sk_buff *skb)
                goto drop;
        }
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        if (ip_options_compile(NULL, skb)) {
                IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS);
@@ -328,7 +328,7 @@ drop:
 
 static inline int ip_rcv_finish(struct sk_buff *skb)
 {
-       struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
 
        /*
         *      Initialise the virtual path cache for the packet. It describes
@@ -389,7 +389,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
        if (!pskb_may_pull(skb, sizeof(struct iphdr)))
                goto inhdr_error;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        /*
         *      RFC1122: 3.1.2.2 MUST silently discard any IP frame that fails the checksum.
@@ -408,7 +408,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
        if (!pskb_may_pull(skb, iph->ihl*4))
                goto inhdr_error;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
                goto inhdr_error;
index f7e9db61256597ff5457878828f1ad86a7f32dbb..251346828cb4ceca55d2f3b5622698b4fbd26249 100644 (file)
@@ -110,7 +110,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
        if (skb->dst)
                daddr = ((struct rtable*)skb->dst)->rt_spec_dst;
        else
-               daddr = skb->nh.iph->daddr;
+               daddr = ip_hdr(skb)->daddr;
 
        if (sopt->rr) {
                optlen  = sptr[sopt->rr+1];
@@ -180,7 +180,8 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
                        /*
                         * RFC1812 requires to fix illegal source routes.
                         */
-                       if (memcmp(&skb->nh.iph->saddr, &start[soffset+3], 4) == 0)
+                       if (memcmp(&ip_hdr(skb)->saddr,
+                                  &start[soffset + 3], 4) == 0)
                                doffset -= 4;
                }
                if (doffset > 3) {
@@ -269,7 +270,8 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
                optptr = iph + sizeof(struct iphdr);
                opt->is_data = 0;
        } else {
-               optptr = opt->is_data ? opt->__data : (unsigned char*)&(skb->nh.iph[1]);
+               optptr = opt->is_data ? opt->__data :
+                                       (unsigned char *)&(ip_hdr(skb)[1]);
                iph = optptr - sizeof(struct iphdr);
        }
 
@@ -587,7 +589,7 @@ void ip_forward_options(struct sk_buff *skb)
                if (srrptr + 3 <= srrspace) {
                        opt->is_changed = 1;
                        ip_rt_get_source(&optptr[srrptr-1], rt);
-                       skb->nh.iph->daddr = rt->rt_dst;
+                       ip_hdr(skb)->daddr = rt->rt_dst;
                        optptr[2] = srrptr+4;
                } else if (net_ratelimit())
                        printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n");
@@ -599,7 +601,7 @@ void ip_forward_options(struct sk_buff *skb)
        }
        if (opt->is_changed) {
                opt->is_changed = 0;
-               ip_send_check(skb->nh.iph);
+               ip_send_check(ip_hdr(skb));
        }
 }
 
@@ -608,7 +610,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
        struct ip_options *opt = &(IPCB(skb)->opt);
        int srrspace, srrptr;
        __be32 nexthop;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        unsigned char *optptr = skb_network_header(skb) + opt->srr;
        struct rtable *rt = (struct rtable*)skb->dst;
        struct rtable *rt2;
index 15de9d43950e061baa20e09c8a1cd86a1578955e..1abc48899f2dfaf4bc7b7375cd21daf37229dcc5 100644 (file)
@@ -127,7 +127,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
        /* Build the IP header. */
        skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0));
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        iph->version  = 4;
        iph->ihl      = 5;
        iph->tos      = inet->tos;
@@ -245,7 +245,7 @@ int ip_mc_output(struct sk_buff *skb)
 
                /* Multicasts with ttl 0 must not go beyond the host */
 
-               if (skb->nh.iph->ttl == 0) {
+               if (ip_hdr(skb)->ttl == 0) {
                        kfree_skb(skb);
                        return 0;
                }
@@ -332,7 +332,7 @@ packet_routed:
        /* OK, we know where to send it, allocate and build IP header. */
        skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0));
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
        iph->tot_len = htons(skb->len);
        if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok)
@@ -428,7 +428,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
         *      Point into the IP datagram header.
         */
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        if (unlikely((iph->frag_off & htons(IP_DF)) && !skb->local_df)) {
                IP_INC_STATS(IPSTATS_MIB_FRAGFAILS);
@@ -504,7 +504,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
                                __skb_push(frag, hlen);
                                skb_reset_network_header(frag);
                                memcpy(skb_network_header(frag), iph, hlen);
-                               iph = frag->nh.iph;
+                               iph = ip_hdr(frag);
                                iph->tot_len = htons(frag->len);
                                ip_copy_metadata(frag, skb);
                                if (offset == 0)
@@ -619,7 +619,7 @@ slow_path:
                /*
                 *      Fill in the new header fields.
                 */
-               iph = skb2->nh.iph;
+               iph = ip_hdr(skb2);
                iph->frag_off = htons((offset >> 3));
 
                /* ANK: dirty, but effective trick. Upgrade options only if
@@ -1125,7 +1125,7 @@ ssize_t   ip_append_page(struct sock *sk, struct page *page,
                         */
                        data = skb_put(skb, fragheaderlen + fraggap);
                        skb_reset_network_header(skb);
-                       iph = skb->nh.iph;
+                       iph = ip_hdr(skb);
                        data += fragheaderlen;
                        skb->h.raw = data;
 
@@ -1352,7 +1352,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
                struct flowi fl = { .nl_u = { .ip4_u =
                                              { .daddr = daddr,
                                                .saddr = rt->rt_spec_dst,
-                                               .tos = RT_TOS(skb->nh.iph->tos) } },
+                                               .tos = RT_TOS(ip_hdr(skb)->tos) } },
                                    /* Not quite clean, but right. */
                                    .uli_u = { .ports =
                                               { .sport = skb->h.th->dest,
@@ -1370,9 +1370,9 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
           with locally disabled BH and that sk cannot be already spinlocked.
         */
        bh_lock_sock(sk);
-       inet->tos = skb->nh.iph->tos;
+       inet->tos = ip_hdr(skb)->tos;
        sk->sk_priority = skb->priority;
-       sk->sk_protocol = skb->nh.iph->protocol;
+       sk->sk_protocol = ip_hdr(skb)->protocol;
        ip_append_data(sk, ip_reply_glue_bits, arg->iov->iov_base, len, 0,
                       &ipc, rt, MSG_DONTWAIT);
        if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
index 70888e1ef6b7410d6b10f11940c2deb4052eae88..fabc250e16dd07dd4fc5a6578c000b2c22f358ab 100644 (file)
@@ -59,7 +59,7 @@ static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb)
        struct in_pktinfo info;
        struct rtable *rt = (struct rtable *)skb->dst;
 
-       info.ipi_addr.s_addr = skb->nh.iph->daddr;
+       info.ipi_addr.s_addr = ip_hdr(skb)->daddr;
        if (rt) {
                info.ipi_ifindex = rt->rt_iif;
                info.ipi_spec_dst.s_addr = rt->rt_spec_dst;
@@ -73,13 +73,13 @@ static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb)
 
 static void ip_cmsg_recv_ttl(struct msghdr *msg, struct sk_buff *skb)
 {
-       int ttl = skb->nh.iph->ttl;
+       int ttl = ip_hdr(skb)->ttl;
        put_cmsg(msg, SOL_IP, IP_TTL, sizeof(int), &ttl);
 }
 
 static void ip_cmsg_recv_tos(struct msghdr *msg, struct sk_buff *skb)
 {
-       put_cmsg(msg, SOL_IP, IP_TOS, 1, &skb->nh.iph->tos);
+       put_cmsg(msg, SOL_IP, IP_TOS, 1, &ip_hdr(skb)->tos);
 }
 
 static void ip_cmsg_recv_opts(struct msghdr *msg, struct sk_buff *skb)
@@ -87,7 +87,8 @@ static void ip_cmsg_recv_opts(struct msghdr *msg, struct sk_buff *skb)
        if (IPCB(skb)->opt.optlen == 0)
                return;
 
-       put_cmsg(msg, SOL_IP, IP_RECVOPTS, IPCB(skb)->opt.optlen, skb->nh.iph+1);
+       put_cmsg(msg, SOL_IP, IP_RECVOPTS, IPCB(skb)->opt.optlen,
+                ip_hdr(skb) + 1);
 }
 
 
@@ -299,7 +300,7 @@ void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 port, u32 inf
 
        skb_put(skb, sizeof(struct iphdr));
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        iph->daddr = daddr;
 
        serr = SKB_EXT_ERR(skb);
@@ -369,7 +370,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len)
                struct inet_sock *inet = inet_sk(sk);
 
                sin->sin_family = AF_INET;
-               sin->sin_addr.s_addr = skb->nh.iph->saddr;
+               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
                sin->sin_port = 0;
                memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
                if (inet->cmsg_flags)
index aa704b88f014fa7118a8ccfc92fc067b65108c48..8eb46064c525182da155a91f266b5663b0243d15 100644 (file)
@@ -43,21 +43,15 @@ static LIST_HEAD(ipcomp_tfms_list);
 
 static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
 {
-       int err, plen, dlen;
        struct ipcomp_data *ipcd = x->data;
-       u8 *start, *scratch;
-       struct crypto_comp *tfm;
-       int cpu;
-
-       plen = skb->len;
-       dlen = IPCOMP_SCRATCH_SIZE;
-       start = skb->data;
+       const int plen = skb->len;
+       int dlen = IPCOMP_SCRATCH_SIZE;
+       const u8 *start = skb->data;
+       const int cpu = get_cpu();
+       u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
+       struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
+       int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
 
-       cpu = get_cpu();
-       scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
-       tfm = *per_cpu_ptr(ipcd->tfms, cpu);
-
-       err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
        if (err)
                goto out;
 
@@ -90,7 +84,7 @@ static int ipcomp_input(struct xfrm_state *x, struct sk_buff *skb)
        skb->ip_summed = CHECKSUM_NONE;
 
        /* Remove ipcomp header and decompress original payload */
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        ipch = (void *)skb->data;
        iph->protocol = ipch->nexthdr;
        skb->h.raw = skb->nh.raw + sizeof(*ipch);
@@ -103,23 +97,16 @@ out:
 
 static int ipcomp_compress(struct xfrm_state *x, struct sk_buff *skb)
 {
-       int err, plen, dlen, ihlen;
-       struct iphdr *iph = skb->nh.iph;
        struct ipcomp_data *ipcd = x->data;
-       u8 *start, *scratch;
-       struct crypto_comp *tfm;
-       int cpu;
+       const int ihlen = ip_hdrlen(skb);
+       const int plen = skb->len - ihlen;
+       int dlen = IPCOMP_SCRATCH_SIZE;
+       u8 *start = skb->data + ihlen;
+       const int cpu = get_cpu();
+       u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
+       struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
+       int err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
 
-       ihlen = iph->ihl * 4;
-       plen = skb->len - ihlen;
-       dlen = IPCOMP_SCRATCH_SIZE;
-       start = skb->data + ihlen;
-
-       cpu = get_cpu();
-       scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
-       tfm = *per_cpu_ptr(ipcd->tfms, cpu);
-
-       err = crypto_comp_compress(tfm, start, plen, scratch, &dlen);
        if (err)
                goto out;
 
@@ -142,12 +129,11 @@ out:
 static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
 {
        int err;
-       struct iphdr *iph;
        struct ip_comp_hdr *ipch;
        struct ipcomp_data *ipcd = x->data;
        int hdr_len = 0;
+       struct iphdr *iph = ip_hdr(skb);
 
-       iph = skb->nh.iph;
        iph->tot_len = htons(skb->len);
        hdr_len = iph->ihl * 4;
        if ((skb->len - hdr_len) < ipcd->threshold) {
@@ -159,7 +145,7 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb)
                goto out_ok;
 
        err = ipcomp_compress(x, skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        if (err) {
                goto out_ok;
index 6e8998409cbe6eb817ecd1cc69b4df7a2b0c8cf1..6b91c9f5d57adb5f9707887bbacba38dba03bd21 100644 (file)
@@ -703,7 +703,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
 
        /* Construct IP header */
        skb_reset_network_header(skb);
-       h = skb->nh.iph;
+       h = ip_hdr(skb);
        h->version = 4;
        h->ihl = 5;
        h->tot_len = htons(sizeof(struct bootp_pkt));
@@ -846,7 +846,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
                           sizeof(struct udphdr)))
                goto drop;
 
-       b = (struct bootp_pkt *) skb->nh.iph;
+       b = (struct bootp_pkt *)skb_network_header(skb);
        h = &b->iph;
 
        if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
@@ -884,7 +884,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
        if (!pskb_may_pull(skb, skb->len))
                goto drop;
 
-       b = (struct bootp_pkt *) skb->nh.iph;
+       b = (struct bootp_pkt *)skb_network_header(skb);
        h = &b->iph;
 
        /* One reply at a time, please. */
index 843cc09f961f756edbe6684c684b3092adcd4d0f..b7f6ff4705b03e30323b7565b8ef4314d8b36816 100644 (file)
@@ -461,9 +461,10 @@ out:
 #endif
 }
 
-static inline void ipip_ecn_decapsulate(struct iphdr *outer_iph, struct sk_buff *skb)
+static inline void ipip_ecn_decapsulate(const struct iphdr *outer_iph,
+                                       struct sk_buff *skb)
 {
-       struct iphdr *inner_iph = skb->nh.iph;
+       struct iphdr *inner_iph = ip_hdr(skb);
 
        if (INET_ECN_is_ce(outer_iph->tos))
                IP_ECN_set_ce(inner_iph);
@@ -471,10 +472,8 @@ static inline void ipip_ecn_decapsulate(struct iphdr *outer_iph, struct sk_buff
 
 static int ipip_rcv(struct sk_buff *skb)
 {
-       struct iphdr *iph;
        struct ip_tunnel *tunnel;
-
-       iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
 
        read_lock(&ipip_lock);
        if ((tunnel = ipip_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) {
@@ -521,7 +520,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
        __be16 df = tiph->frag_off;
        struct rtable *rt;                      /* Route to the other host */
        struct net_device *tdev;                        /* Device to other host */
-       struct iphdr  *old_iph = skb->nh.iph;
+       struct iphdr  *old_iph = ip_hdr(skb);
        struct iphdr  *iph;                     /* Our new IP header */
        int    max_headroom;                    /* The extra header space needed */
        __be32 dst = tiph->daddr;
@@ -615,7 +614,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                        skb_set_owner_w(new_skb, skb->sk);
                dev_kfree_skb(skb);
                skb = new_skb;
-               old_iph = skb->nh.iph;
+               old_iph = ip_hdr(skb);
        }
 
        skb->h.raw = skb->nh.raw;
@@ -631,7 +630,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
         *      Push down and install the IPIP header.
         */
 
-       iph                     =       skb->nh.iph;
+       iph                     =       ip_hdr(skb);
        iph->version            =       4;
        iph->ihl                =       sizeof(struct iphdr)>>2;
        iph->frag_off           =       df;
index b24dffe3bd464c157f7e4556d0640d493f429beb..e0021499093fc8613859395585bc19a6777af8c9 100644 (file)
@@ -303,7 +303,7 @@ static void ipmr_destroy_unres(struct mfc_cache *c)
        atomic_dec(&cache_resolve_queue_len);
 
        while ((skb=skb_dequeue(&c->mfc_un.unres.unresolved))) {
-               if (skb->nh.iph->version == 0) {
+               if (ip_hdr(skb)->version == 0) {
                        struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
                        nlh->nlmsg_type = NLMSG_ERROR;
                        nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nlmsgerr));
@@ -509,7 +509,7 @@ static void ipmr_cache_resolve(struct mfc_cache *uc, struct mfc_cache *c)
         */
 
        while ((skb=__skb_dequeue(&uc->mfc_un.unres.unresolved))) {
-               if (skb->nh.iph->version == 0) {
+               if (ip_hdr(skb)->version == 0) {
                        struct nlmsghdr *nlh = (struct nlmsghdr *)skb_pull(skb, sizeof(struct iphdr));
 
                        if (ipmr_fill_mroute(skb, c, NLMSG_DATA(nlh)) > 0) {
@@ -569,8 +569,9 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
                msg->im_msgtype = IGMPMSG_WHOLEPKT;
                msg->im_mbz = 0;
                msg->im_vif = reg_vif_num;
-               skb->nh.iph->ihl = sizeof(struct iphdr) >> 2;
-               skb->nh.iph->tot_len = htons(ntohs(pkt->nh.iph->tot_len) + sizeof(struct iphdr));
+               ip_hdr(skb)->ihl = sizeof(struct iphdr) >> 2;
+               ip_hdr(skb)->tot_len = htons(ntohs(ip_hdr(pkt)->tot_len) +
+                                            sizeof(struct iphdr));
        } else
 #endif
        {
@@ -579,10 +580,10 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
         *      Copy the IP header
         */
 
-       skb->nh.iph = (struct iphdr *)skb_put(skb, ihl);
+       skb->nh.raw = skb_put(skb, ihl);
        memcpy(skb->data,pkt->data,ihl);
-       skb->nh.iph->protocol = 0;                      /* Flag to the kernel this is a route add */
-       msg = (struct igmpmsg*)skb->nh.iph;
+       ip_hdr(skb)->protocol = 0;                      /* Flag to the kernel this is a route add */
+       msg = (struct igmpmsg *)skb_network_header(skb);
        msg->im_vif = vifi;
        skb->dst = dst_clone(pkt->dst);
 
@@ -594,7 +595,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
        igmp->type      =
        msg->im_msgtype = assert;
        igmp->code      =       0;
-       skb->nh.iph->tot_len=htons(skb->len);                   /* Fix the length */
+       ip_hdr(skb)->tot_len = htons(skb->len);                 /* Fix the length */
        skb->h.raw = skb->nh.raw;
        }
 
@@ -624,11 +625,12 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
 {
        int err;
        struct mfc_cache *c;
+       const struct iphdr *iph = ip_hdr(skb);
 
        spin_lock_bh(&mfc_unres_lock);
        for (c=mfc_unres_queue; c; c=c->next) {
-               if (c->mfc_mcastgrp == skb->nh.iph->daddr &&
-                   c->mfc_origin == skb->nh.iph->saddr)
+               if (c->mfc_mcastgrp == iph->daddr &&
+                   c->mfc_origin == iph->saddr)
                        break;
        }
 
@@ -648,9 +650,9 @@ ipmr_cache_unresolved(vifi_t vifi, struct sk_buff *skb)
                /*
                 *      Fill in the new cache entry
                 */
-               c->mfc_parent=-1;
-               c->mfc_origin=skb->nh.iph->saddr;
-               c->mfc_mcastgrp=skb->nh.iph->daddr;
+               c->mfc_parent   = -1;
+               c->mfc_origin   = iph->saddr;
+               c->mfc_mcastgrp = iph->daddr;
 
                /*
                 *      Reflect first query at mrouted.
@@ -1096,12 +1098,12 @@ static struct notifier_block ip_mr_notifier={
 static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
 {
        struct iphdr *iph;
-       struct iphdr *old_iph = skb->nh.iph;
+       struct iphdr *old_iph = ip_hdr(skb);
 
        skb_push(skb, sizeof(struct iphdr));
-       skb->h.ipiph = skb->nh.iph;
+       skb->h.raw = skb->nh.raw;
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        iph->version    =       4;
        iph->tos        =       old_iph->tos;
@@ -1137,7 +1139,7 @@ static inline int ipmr_forward_finish(struct sk_buff *skb)
 
 static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
 {
-       struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
        struct vif_device *vif = &vif_table[vifi];
        struct net_device *dev;
        struct rtable *rt;
@@ -1203,8 +1205,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
 
        dst_release(skb->dst);
        skb->dst = &rt->u.dst;
-       iph = skb->nh.iph;
-       ip_decrease_ttl(iph);
+       ip_decrease_ttl(ip_hdr(skb));
 
        /* FIXME: forward and output firewalls used to be called here.
         * What do we do with netfilter? -- RR */
@@ -1304,7 +1305,7 @@ static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local
         *      Forward the frame
         */
        for (ct = cache->mfc_un.res.maxvif-1; ct >= cache->mfc_un.res.minvif; ct--) {
-               if (skb->nh.iph->ttl > cache->mfc_un.res.ttls[ct]) {
+               if (ip_hdr(skb)->ttl > cache->mfc_un.res.ttls[ct]) {
                        if (psend != -1) {
                                struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
                                if (skb2)
@@ -1350,7 +1351,7 @@ int ip_mr_input(struct sk_buff *skb)
                    if (IPCB(skb)->opt.router_alert) {
                            if (ip_call_ra_chain(skb))
                                    return 0;
-                   } else if (skb->nh.iph->protocol == IPPROTO_IGMP){
+                   } else if (ip_hdr(skb)->protocol == IPPROTO_IGMP){
                            /* IGMPv1 (and broken IGMPv2 implementations sort of
                               Cisco IOS <= 11.2(8)) do not put router alert
                               option to IGMP packets destined to routable
@@ -1369,7 +1370,7 @@ int ip_mr_input(struct sk_buff *skb)
        }
 
        read_lock(&mrt_lock);
-       cache = ipmr_cache_find(skb->nh.iph->saddr, skb->nh.iph->daddr);
+       cache = ipmr_cache_find(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr);
 
        /*
         *      No usable cache entry
@@ -1580,6 +1581,7 @@ int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait)
 
        if (cache==NULL) {
                struct sk_buff *skb2;
+               struct iphdr *iph;
                struct net_device *dev;
                int vif;
 
@@ -1601,10 +1603,11 @@ int ipmr_get_route(struct sk_buff *skb, struct rtmsg *rtm, int nowait)
 
                skb_push(skb2, sizeof(struct iphdr));
                skb_reset_network_header(skb2);
-               skb2->nh.iph->ihl = sizeof(struct iphdr)>>2;
-               skb2->nh.iph->saddr = rt->rt_src;
-               skb2->nh.iph->daddr = rt->rt_dst;
-               skb2->nh.iph->version = 0;
+               iph = ip_hdr(skb2);
+               iph->ihl = sizeof(struct iphdr) >> 2;
+               iph->saddr = rt->rt_src;
+               iph->daddr = rt->rt_dst;
+               iph->version = 0;
                err = ipmr_cache_unresolved(vif, skb2);
                read_unlock(&mrt_lock);
                return err;
index e5beab28cd0f1e38cb324874b071b14e06f71d52..c8a822c0aa757279d2b7be016385c29fbed33478 100644 (file)
@@ -577,7 +577,6 @@ static const struct file_operations ip_vs_app_fops = {
 int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
                      char *o_buf, int o_len, char *n_buf, int n_len)
 {
-       struct iphdr *iph;
        int diff;
        int o_offset;
        int o_left;
@@ -607,8 +606,7 @@ int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri,
        }
 
        /* must update the iph total length here */
-       iph = skb->nh.iph;
-       iph->tot_len = htons(skb->len);
+       ip_hdr(skb)->tot_len = htons(skb->len);
 
        LeaveFunction(9);
        return 0;
index 7893c00a91fe78eac73011fe95ab1e42193eb898..62cfbed317bf07176d6bbcd67545381f141c3711 100644 (file)
@@ -212,7 +212,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
                    __be16 ports[2])
 {
        struct ip_vs_conn *cp = NULL;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct ip_vs_dest *dest;
        struct ip_vs_conn *ct;
        __be16  dport;   /* destination port to forward */
@@ -381,7 +381,7 @@ struct ip_vs_conn *
 ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 {
        struct ip_vs_conn *cp = NULL;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct ip_vs_dest *dest;
        __be16 _ports[2], *pptr;
 
@@ -447,7 +447,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
                struct ip_vs_protocol *pp)
 {
        __be16 _ports[2], *pptr;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
 
        pptr = skb_header_pointer(skb, iph->ihl*4,
                                  sizeof(_ports), _ports);
@@ -546,7 +546,7 @@ ip_vs_gather_frags(struct sk_buff *skb, u_int32_t user)
 {
        skb = ip_defrag(skb, user);
        if (skb)
-               ip_send_check(skb->nh.iph);
+               ip_send_check(ip_hdr(skb));
        return skb;
 }
 
@@ -557,7 +557,7 @@ ip_vs_gather_frags(struct sk_buff *skb, u_int32_t user)
 void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
                    struct ip_vs_conn *cp, int inout)
 {
-       struct iphdr *iph        = skb->nh.iph;
+       struct iphdr *iph        = ip_hdr(skb);
        unsigned int icmp_offset = iph->ihl*4;
        struct icmphdr *icmph    = (struct icmphdr *)(skb_network_header(skb) +
                                                      icmp_offset);
@@ -618,14 +618,14 @@ static int ip_vs_out_icmp(struct sk_buff **pskb, int *related)
        *related = 1;
 
        /* reassemble IP fragments */
-       if (skb->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
+       if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
                skb = ip_vs_gather_frags(skb, IP_DEFRAG_VS_OUT);
                if (!skb)
                        return NF_STOLEN;
                *pskb = skb;
        }
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        offset = ihl = iph->ihl * 4;
        ic = skb_header_pointer(skb, offset, sizeof(_icmph), &_icmph);
        if (ic == NULL)
@@ -740,14 +740,14 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
        if (skb->ipvs_property)
                return NF_ACCEPT;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (unlikely(iph->protocol == IPPROTO_ICMP)) {
                int related, verdict = ip_vs_out_icmp(pskb, &related);
 
                if (related)
                        return verdict;
                skb = *pskb;
-               iph = skb->nh.iph;
+               iph = ip_hdr(skb);
        }
 
        pp = ip_vs_proto_get(iph->protocol);
@@ -760,7 +760,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
                skb = ip_vs_gather_frags(skb, IP_DEFRAG_VS_OUT);
                if (!skb)
                        return NF_STOLEN;
-               iph = skb->nh.iph;
+               iph = ip_hdr(skb);
                *pskb = skb;
        }
 
@@ -810,8 +810,8 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
        if (pp->snat_handler && !pp->snat_handler(pskb, pp, cp))
                goto drop;
        skb = *pskb;
-       skb->nh.iph->saddr = cp->vaddr;
-       ip_send_check(skb->nh.iph);
+       ip_hdr(skb)->saddr = cp->vaddr;
+       ip_send_check(ip_hdr(skb));
 
        /* For policy routing, packets originating from this
         * machine itself may be routed differently to packets
@@ -861,7 +861,7 @@ ip_vs_in_icmp(struct sk_buff **pskb, int *related, unsigned int hooknum)
        *related = 1;
 
        /* reassemble IP fragments */
-       if (skb->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
+       if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
                skb = ip_vs_gather_frags(skb,
                                         hooknum == NF_IP_LOCAL_IN ?
                                         IP_DEFRAG_VS_IN : IP_DEFRAG_VS_FWD);
@@ -870,7 +870,7 @@ ip_vs_in_icmp(struct sk_buff **pskb, int *related, unsigned int hooknum)
                *pskb = skb;
        }
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        offset = ihl = iph->ihl * 4;
        ic = skb_header_pointer(skb, offset, sizeof(_icmph), &_icmph);
        if (ic == NULL)
@@ -966,19 +966,19 @@ ip_vs_in(unsigned int hooknum, struct sk_buff **pskb,
                     || skb->dev == &loopback_dev || skb->sk)) {
                IP_VS_DBG(12, "packet type=%d proto=%d daddr=%d.%d.%d.%d ignored\n",
                          skb->pkt_type,
-                         skb->nh.iph->protocol,
-                         NIPQUAD(skb->nh.iph->daddr));
+                         ip_hdr(skb)->protocol,
+                         NIPQUAD(ip_hdr(skb)->daddr));
                return NF_ACCEPT;
        }
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (unlikely(iph->protocol == IPPROTO_ICMP)) {
                int related, verdict = ip_vs_in_icmp(pskb, &related, hooknum);
 
                if (related)
                        return verdict;
                skb = *pskb;
-               iph = skb->nh.iph;
+               iph = ip_hdr(skb);
        }
 
        /* Protocol supported? */
@@ -1064,7 +1064,7 @@ ip_vs_forward_icmp(unsigned int hooknum, struct sk_buff **pskb,
 {
        int r;
 
-       if ((*pskb)->nh.iph->protocol != IPPROTO_ICMP)
+       if (ip_hdr(*pskb)->protocol != IPPROTO_ICMP)
                return NF_ACCEPT;
 
        return ip_vs_in_icmp(pskb, &r, hooknum);
index 502111fba87284ae6fe11ab944d3720a0b6b8a02..dcf5d46aaa5e45879d191c7ccff8250fa1c6b44d 100644 (file)
@@ -204,7 +204,7 @@ ip_vs_dh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 {
        struct ip_vs_dest *dest;
        struct ip_vs_dh_bucket *tbl;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
 
        IP_VS_DBG(6, "ip_vs_dh_schedule(): Scheduling...\n");
 
index 847c47af040c475eef93f51156721c2da38110a0..25bd68967305e3492a5bf6e30ccab4a7da25df7e 100644 (file)
@@ -159,7 +159,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
                return 0;
 
        if (cp->app_data == &ip_vs_ftp_pasv) {
-               iph = (*pskb)->nh.iph;
+               iph = ip_hdr(*pskb);
                th = (struct tcphdr *)&(((char *)iph)[iph->ihl*4]);
                data = (char *)th + (th->doff << 2);
                data_limit = (*pskb)->tail;
@@ -262,7 +262,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
        /*
         * Detecting whether it is passive
         */
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        th = (struct tcphdr *)&(((char *)iph)[iph->ihl*4]);
 
        /* Since there may be OPTIONS in the TCP packet and the HLEN is
index c801273cb881151d65617f6c4ba6699bb26378ad..052f4ed59174ac0b40012712e33e06fabe0a72cb 100644 (file)
@@ -521,7 +521,7 @@ ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        struct ip_vs_dest *dest;
        struct ip_vs_lblc_table *tbl;
        struct ip_vs_lblc_entry *en;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
 
        IP_VS_DBG(6, "ip_vs_lblc_schedule(): Scheduling...\n");
 
index 23f9b9e73c850f9a00e4d38c979023ad062f857b..6225acac7a3baf322e96db668ff0b2d11483b9af 100644 (file)
@@ -775,7 +775,7 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        struct ip_vs_dest *dest;
        struct ip_vs_lblcr_table *tbl;
        struct ip_vs_lblcr_entry *en;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
 
        IP_VS_DBG(6, "ip_vs_lblcr_schedule(): Scheduling...\n");
 
index e65382da713e74d782c310b56a2dee930ae72057..e65577a77006f3ed199f8e8c640a11123c97326e 100644 (file)
@@ -83,8 +83,8 @@ tcp_conn_schedule(struct sk_buff *skb,
        }
 
        if (th->syn &&
-           (svc = ip_vs_service_get(skb->mark, skb->nh.iph->protocol,
-                                    skb->nh.iph->daddr, th->dest))) {
+           (svc = ip_vs_service_get(skb->mark, ip_hdr(skb)->protocol,
+                                    ip_hdr(skb)->daddr, th->dest))) {
                if (ip_vs_todrop()) {
                        /*
                         * It seems that we are very loaded.
@@ -142,7 +142,7 @@ tcp_snat_handler(struct sk_buff **pskb,
                        return 0;
        }
 
-       tcph = (void *)(*pskb)->nh.iph + tcphoff;
+       tcph = (void *)ip_hdr(*pskb) + tcphoff;
        tcph->source = cp->vport;
 
        /* Adjust TCP checksums */
@@ -193,7 +193,7 @@ tcp_dnat_handler(struct sk_buff **pskb,
                        return 0;
        }
 
-       tcph = (void *)(*pskb)->nh.iph + tcphoff;
+       tcph = (void *)ip_hdr(*pskb) + tcphoff;
        tcph->dest = cp->dport;
 
        /*
@@ -229,9 +229,9 @@ tcp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
        case CHECKSUM_NONE:
                skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
        case CHECKSUM_COMPLETE:
-               if (csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
+               if (csum_tcpudp_magic(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
                                      skb->len - tcphoff,
-                                     skb->nh.iph->protocol, skb->csum)) {
+                                     ip_hdr(skb)->protocol, skb->csum)) {
                        IP_VS_DBG_RL_PKT(0, pp, skb, 0,
                                         "Failed checksum for");
                        return 0;
index 2cd950638923c7784be66ae53dc5dffbfb0289bf..8ee5fe6a101dca59f0e84bf9be4833584a8dd40e 100644 (file)
@@ -89,8 +89,8 @@ udp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp,
                return 0;
        }
 
-       if ((svc = ip_vs_service_get(skb->mark, skb->nh.iph->protocol,
-                                    skb->nh.iph->daddr, uh->dest))) {
+       if ((svc = ip_vs_service_get(skb->mark, ip_hdr(skb)->protocol,
+                                    ip_hdr(skb)->daddr, uh->dest))) {
                if (ip_vs_todrop()) {
                        /*
                         * It seems that we are very loaded.
@@ -151,7 +151,7 @@ udp_snat_handler(struct sk_buff **pskb,
                        return 0;
        }
 
-       udph = (void *)(*pskb)->nh.iph + udphoff;
+       udph = (void *)ip_hdr(*pskb) + udphoff;
        udph->source = cp->vport;
 
        /*
@@ -206,7 +206,7 @@ udp_dnat_handler(struct sk_buff **pskb,
                        return 0;
        }
 
-       udph = (void *)(*pskb)->nh.iph + udphoff;
+       udph = (void *)ip_hdr(*pskb) + udphoff;
        udph->dest = cp->dport;
 
        /*
@@ -251,10 +251,10 @@ udp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
                        skb->csum = skb_checksum(skb, udphoff,
                                                 skb->len - udphoff, 0);
                case CHECKSUM_COMPLETE:
-                       if (csum_tcpudp_magic(skb->nh.iph->saddr,
-                                             skb->nh.iph->daddr,
+                       if (csum_tcpudp_magic(ip_hdr(skb)->saddr,
+                                             ip_hdr(skb)->daddr,
                                              skb->len - udphoff,
-                                             skb->nh.iph->protocol,
+                                             ip_hdr(skb)->protocol,
                                              skb->csum)) {
                                IP_VS_DBG_RL_PKT(0, pp, skb, 0,
                                                 "Failed checksum for");
index 338668f88fe286a9b9c3cfaa05e32c7c334b01ea..1b25b00ef1e152c17578799c31e1212d2b990cb5 100644 (file)
@@ -201,7 +201,7 @@ ip_vs_sh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 {
        struct ip_vs_dest *dest;
        struct ip_vs_sh_bucket *tbl;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
 
        IP_VS_DBG(6, "ip_vs_sh_schedule(): Scheduling...\n");
 
index d1403d0855eda8e55e4314e5a89beb948a9419d0..a7aee68220335eb6a83c60f2984d5beb4017a3a1 100644 (file)
@@ -156,7 +156,7 @@ ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                  struct ip_vs_protocol *pp)
 {
        struct rtable *rt;                      /* Route to the other host */
-       struct iphdr  *iph = skb->nh.iph;
+       struct iphdr  *iph = ip_hdr(skb);
        u8     tos = iph->tos;
        int    mtu;
        struct flowi fl = {
@@ -193,7 +193,7 @@ ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                ip_rt_put(rt);
                return NF_STOLEN;
        }
-       ip_send_check(skb->nh.iph);
+       ip_send_check(ip_hdr(skb));
 
        /* drop old route */
        dst_release(skb->dst);
@@ -226,7 +226,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 {
        struct rtable *rt;              /* Route to the other host */
        int mtu;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
 
        EnterFunction(10);
 
@@ -266,8 +266,8 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* mangle the packet */
        if (pp->dnat_handler && !pp->dnat_handler(&skb, pp, cp))
                goto tx_error;
-       skb->nh.iph->daddr = cp->daddr;
-       ip_send_check(skb->nh.iph);
+       ip_hdr(skb)->daddr = cp->daddr;
+       ip_send_check(ip_hdr(skb));
 
        IP_VS_DBG_PKT(10, pp, skb, 0, "After DNAT");
 
@@ -320,7 +320,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
 {
        struct rtable *rt;                      /* Route to the other host */
        struct net_device *tdev;                /* Device to other host */
-       struct iphdr  *old_iph = skb->nh.iph;
+       struct iphdr  *old_iph = ip_hdr(skb);
        u8     tos = old_iph->tos;
        __be16 df = old_iph->frag_off;
        struct iphdr  *iph;                     /* Our new IP header */
@@ -377,7 +377,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                }
                kfree_skb(skb);
                skb = new_skb;
-               old_iph = skb->nh.iph;
+               old_iph = ip_hdr(skb);
        }
 
        skb->h.raw = (void *) old_iph;
@@ -396,7 +396,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /*
         *      Push down and install the IPIP header.
         */
-       iph                     =       skb->nh.iph;
+       iph                     =       ip_hdr(skb);
        iph->version            =       4;
        iph->ihl                =       sizeof(struct iphdr)>>2;
        iph->frag_off           =       df;
@@ -436,7 +436,7 @@ ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
              struct ip_vs_protocol *pp)
 {
        struct rtable *rt;                      /* Route to the other host */
-       struct iphdr  *iph = skb->nh.iph;
+       struct iphdr  *iph = ip_hdr(skb);
        int    mtu;
 
        EnterFunction(10);
@@ -461,7 +461,7 @@ ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
                ip_rt_put(rt);
                return NF_STOLEN;
        }
-       ip_send_check(skb->nh.iph);
+       ip_send_check(ip_hdr(skb));
 
        /* drop old route */
        dst_release(skb->dst);
@@ -515,12 +515,12 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
         * mangle and send the packet here (only for VS/NAT)
         */
 
-       if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(skb->nh.iph->tos))))
+       if (!(rt = __ip_vs_get_out_rt(cp, RT_TOS(ip_hdr(skb)->tos))))
                goto tx_error_icmp;
 
        /* MTU checking */
        mtu = dst_mtu(&rt->u.dst);
-       if ((skb->len > mtu) && (skb->nh.iph->frag_off & htons(IP_DF))) {
+       if ((skb->len > mtu) && (ip_hdr(skb)->frag_off & htons(IP_DF))) {
                ip_rt_put(rt);
                icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
                IP_VS_DBG_RL("ip_vs_in_icmp(): frag needed\n");
index 6069a11514f66a5322074f4783edbb32b1738b92..b44192924f95fed17389482bb8ef47ed6275c2ab 100644 (file)
@@ -10,7 +10,7 @@
 /* route_me_harder function, used by iptable_nat, iptable_mangle + ip_queue */
 int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type)
 {
-       struct iphdr *iph = (*pskb)->nh.iph;
+       const struct iphdr *iph = ip_hdr(*pskb);
        struct rtable *rt;
        struct flowi fl = {};
        struct dst_entry *odst;
@@ -142,7 +142,7 @@ static void nf_ip_saveroute(const struct sk_buff *skb, struct nf_info *info)
        struct ip_rt_info *rt_info = nf_info_reroute(info);
 
        if (info->hook == NF_IP_LOCAL_OUT) {
-               const struct iphdr *iph = skb->nh.iph;
+               const struct iphdr *iph = ip_hdr(skb);
 
                rt_info->tos = iph->tos;
                rt_info->daddr = iph->daddr;
@@ -155,7 +155,7 @@ static int nf_ip_reroute(struct sk_buff **pskb, const struct nf_info *info)
        const struct ip_rt_info *rt_info = nf_info_reroute(info);
 
        if (info->hook == NF_IP_LOCAL_OUT) {
-               struct iphdr *iph = (*pskb)->nh.iph;
+               const struct iphdr *iph = ip_hdr(*pskb);
 
                if (!(iph->tos == rt_info->tos
                      && iph->daddr == rt_info->daddr
@@ -168,7 +168,7 @@ static int nf_ip_reroute(struct sk_buff **pskb, const struct nf_info *info)
 __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
                            unsigned int dataoff, u_int8_t protocol)
 {
-       struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
        __sum16 csum = 0;
 
        switch (skb->ip_summed) {
index 8c013d9f6907c380f0438164eb8dcbd7d7ac5dd3..986c0c81294f8a7819b1642544589d4b0a05b4d0 100644 (file)
@@ -748,9 +748,9 @@ resolve_normal_ct(struct sk_buff *skb,
        struct ip_conntrack_tuple_hash *h;
        struct ip_conntrack *ct;
 
-       IP_NF_ASSERT((skb->nh.iph->frag_off & htons(IP_OFFSET)) == 0);
+       IP_NF_ASSERT((ip_hdr(skb)->frag_off & htons(IP_OFFSET)) == 0);
 
-       if (!ip_ct_get_tuple(skb->nh.iph, skb, ip_hdrlen(skb), &tuple,proto))
+       if (!ip_ct_get_tuple(ip_hdr(skb), skb, ip_hdrlen(skb), &tuple,proto))
                return NULL;
 
        /* look for tuple match */
@@ -811,10 +811,10 @@ unsigned int ip_conntrack_in(unsigned int hooknum,
        }
 
        /* Never happen */
-       if ((*pskb)->nh.iph->frag_off & htons(IP_OFFSET)) {
+       if (ip_hdr(*pskb)->frag_off & htons(IP_OFFSET)) {
                if (net_ratelimit()) {
                printk(KERN_ERR "ip_conntrack_in: Frag of proto %u (hook=%u)\n",
-                      (*pskb)->nh.iph->protocol, hooknum);
+                      ip_hdr(*pskb)->protocol, hooknum);
                }
                return NF_DROP;
        }
@@ -825,17 +825,17 @@ unsigned int ip_conntrack_in(unsigned int hooknum,
        if ((*pskb)->pkt_type == PACKET_BROADCAST) {
                printk("Broadcast packet!\n");
                return NF_ACCEPT;
-       } else if (((*pskb)->nh.iph->daddr & htonl(0x000000FF))
+       } else if ((ip_hdr(*pskb)->daddr & htonl(0x000000FF))
                   == htonl(0x000000FF)) {
                printk("Should bcast: %u.%u.%u.%u->%u.%u.%u.%u (sk=%p, ptype=%u)\n",
-                      NIPQUAD((*pskb)->nh.iph->saddr),
-                      NIPQUAD((*pskb)->nh.iph->daddr),
+                      NIPQUAD(ip_hdr(*pskb)->saddr),
+                      NIPQUAD(ip_hdr(*pskb)->daddr),
                       (*pskb)->sk, (*pskb)->pkt_type);
        }
 #endif
 
        /* rcu_read_lock()ed by nf_hook_slow */
-       proto = __ip_conntrack_proto_find((*pskb)->nh.iph->protocol);
+       proto = __ip_conntrack_proto_find(ip_hdr(*pskb)->protocol);
 
        /* It may be an special packet, error, unclean...
         * inverse of the return code tells to the netfilter
@@ -1152,7 +1152,7 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct,
        if (do_acct) {
                ct->counters[CTINFO2DIR(ctinfo)].packets++;
                ct->counters[CTINFO2DIR(ctinfo)].bytes +=
-                                               ntohs(skb->nh.iph->tot_len);
+                                               ntohs(ip_hdr(skb)->tot_len);
                if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
                    || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
                        event |= IPCT_COUNTER_FILLING;
@@ -1210,7 +1210,7 @@ ip_ct_gather_frags(struct sk_buff *skb, u_int32_t user)
        local_bh_enable();
 
        if (skb)
-               ip_send_check(skb->nh.iph);
+               ip_send_check(ip_hdr(skb));
        return skb;
 }
 
index 5d638149b0e05c4cbd3f05d0c29a57a65e5d84ae..cecb6e0c8ed0a9ed508368d9ecd9366cbfec3b09 100644 (file)
@@ -576,8 +576,8 @@ static int h245_help(struct sk_buff **pskb, struct ip_conntrack *ct,
        /* Process each TPKT */
        while (get_tpkt_data(pskb, ct, ctinfo, &data, &datalen, &dataoff)) {
                DEBUGP("ip_ct_h245: TPKT %u.%u.%u.%u->%u.%u.%u.%u, len=%d\n",
-                      NIPQUAD((*pskb)->nh.iph->saddr),
-                      NIPQUAD((*pskb)->nh.iph->daddr), datalen);
+                      NIPQUAD(ip_hdr(*pskb)->saddr),
+                      NIPQUAD(ip_hdr(*pskb)->daddr), datalen);
 
                /* Decode H.245 signal */
                ret = DecodeMultimediaSystemControlMessage(data, datalen,
@@ -1128,8 +1128,8 @@ static int q931_help(struct sk_buff **pskb, struct ip_conntrack *ct,
        /* Process each TPKT */
        while (get_tpkt_data(pskb, ct, ctinfo, &data, &datalen, &dataoff)) {
                DEBUGP("ip_ct_q931: TPKT %u.%u.%u.%u->%u.%u.%u.%u, len=%d\n",
-                      NIPQUAD((*pskb)->nh.iph->saddr),
-                      NIPQUAD((*pskb)->nh.iph->daddr), datalen);
+                      NIPQUAD(ip_hdr(*pskb)->saddr),
+                      NIPQUAD(ip_hdr(*pskb)->daddr), datalen);
 
                /* Decode Q.931 signal */
                ret = DecodeQ931(data, datalen, &q931);
@@ -1741,8 +1741,8 @@ static int ras_help(struct sk_buff **pskb, struct ip_conntrack *ct,
        if (data == NULL)
                goto accept;
        DEBUGP("ip_ct_ras: RAS message %u.%u.%u.%u->%u.%u.%u.%u, len=%d\n",
-              NIPQUAD((*pskb)->nh.iph->saddr),
-              NIPQUAD((*pskb)->nh.iph->daddr), datalen);
+              NIPQUAD(ip_hdr(*pskb)->saddr),
+              NIPQUAD(ip_hdr(*pskb)->daddr), datalen);
 
        /* Decode RAS message */
        ret = DecodeRasMessage(data, datalen, &ras);
index cc6dd49c9da0060f7fcf40d97a26925c1399440d..df07c5f1d87440c85ba87bca9369a75d6901468b 100644 (file)
@@ -45,7 +45,7 @@ static int help(struct sk_buff **pskb,
                struct ip_conntrack *ct, enum ip_conntrack_info ctinfo)
 {
        struct ip_conntrack_expect *exp;
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        struct rtable *rt = (struct rtable *)(*pskb)->dst;
        struct in_device *in_dev;
        __be32 mask = 0;
index e29c436144b3e912b139d4ba3dc3b1be4790a080..91d0c05c8e861f1195effd4c22b7aca0ec56aa50 100644 (file)
@@ -316,7 +316,7 @@ static int sctp_packet(struct ip_conntrack *conntrack,
                       enum ip_conntrack_info ctinfo)
 {
        enum sctp_conntrack newconntrack, oldsctpstate;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        sctp_sctphdr_t _sctph, *sh;
        sctp_chunkhdr_t _sch, *sch;
        u_int32_t offset, count;
@@ -430,7 +430,7 @@ static int sctp_new(struct ip_conntrack *conntrack,
                    const struct sk_buff *skb)
 {
        enum sctp_conntrack newconntrack;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        sctp_sctphdr_t _sctph, *sh;
        sctp_chunkhdr_t _sch, *sch;
        u_int32_t offset, count;
index fce3a3c6981507d112122ba57b9dc4cca6e757d4..d03436edfd930bcacf10939594837865a1d5e8e1 100644 (file)
@@ -770,8 +770,8 @@ void ip_conntrack_tcp_update(struct sk_buff *skb,
                             struct ip_conntrack *conntrack,
                             enum ip_conntrack_dir dir)
 {
-       struct iphdr *iph = skb->nh.iph;
-       struct tcphdr *tcph = (void *)skb->nh.iph + ip_hdrlen(skb);
+       struct iphdr *iph = ip_hdr(skb);
+       struct tcphdr *tcph = (void *)iph + ip_hdrlen(skb);
        __u32 end;
 #ifdef DEBUGP_VARS
        struct ip_ct_tcp_state *sender = &conntrack->proto.tcp.seen[dir];
@@ -834,13 +834,13 @@ static int tcp_error(struct sk_buff *skb,
                     enum ip_conntrack_info *ctinfo,
                     unsigned int hooknum)
 {
-       struct iphdr *iph = skb->nh.iph;
+       const unsigned int hdrlen = ip_hdrlen(skb);
        struct tcphdr _tcph, *th;
-       unsigned int tcplen = skb->len - iph->ihl * 4;
+       unsigned int tcplen = skb->len - hdrlen;
        u_int8_t tcpflags;
 
        /* Smaller that minimal TCP header? */
-       th = skb_header_pointer(skb, iph->ihl * 4,
+       th = skb_header_pointer(skb, hdrlen,
                                sizeof(_tcph), &_tcph);
        if (th == NULL) {
                if (LOG_INVALID(IPPROTO_TCP))
@@ -863,7 +863,7 @@ static int tcp_error(struct sk_buff *skb,
         */
        /* FIXME: Source route IP option packets --RR */
        if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
-           nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_TCP)) {
+           nf_ip_checksum(skb, hooknum, hdrlen, IPPROTO_TCP)) {
                if (LOG_INVALID(IPPROTO_TCP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                                  "ip_ct_tcp: bad TCP checksum ");
@@ -889,7 +889,7 @@ static int tcp_packet(struct ip_conntrack *conntrack,
 {
        enum tcp_conntrack new_state, old_state;
        enum ip_conntrack_dir dir;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct tcphdr *th, _tcph;
        unsigned long timeout;
        unsigned int index;
@@ -1062,7 +1062,7 @@ static int tcp_new(struct ip_conntrack *conntrack,
                   const struct sk_buff *skb)
 {
        enum tcp_conntrack new_state;
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        struct tcphdr *th, _tcph;
 #ifdef DEBUGP_VARS
        struct ip_ct_tcp_state *sender = &conntrack->proto.tcp.seen[0];
index 14c30c646c7fed33cdfab328ef590f89e5ce83b8..3b47987bf1bbeacace3636dcbfa39ae5982c2a93 100644 (file)
@@ -89,12 +89,12 @@ static int udp_new(struct ip_conntrack *conntrack, const struct sk_buff *skb)
 static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
                     unsigned int hooknum)
 {
-       struct iphdr *iph = skb->nh.iph;
-       unsigned int udplen = skb->len - iph->ihl * 4;
+       const unsigned int hdrlen = ip_hdrlen(skb);
+       unsigned int udplen = skb->len - hdrlen;
        struct udphdr _hdr, *hdr;
 
        /* Header is too small? */
-       hdr = skb_header_pointer(skb, iph->ihl*4, sizeof(_hdr), &_hdr);
+       hdr = skb_header_pointer(skb, hdrlen, sizeof(_hdr), &_hdr);
        if (hdr == NULL) {
                if (LOG_INVALID(IPPROTO_UDP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
@@ -119,7 +119,7 @@ static int udp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
         * because the checksum is assumed to be correct.
         * FIXME: Source route IP option packets --RR */
        if (ip_conntrack_checksum && hooknum == NF_IP_PRE_ROUTING &&
-           nf_ip_checksum(skb, hooknum, iph->ihl * 4, IPPROTO_UDP)) {
+           nf_ip_checksum(skb, hooknum, hdrlen, IPPROTO_UDP)) {
                if (LOG_INVALID(IPPROTO_UDP))
                        nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
                                  "ip_ct_udp: bad UDP checksum ");
index 92609a4dcd745d6e9415dc827be69b9d0c836d65..c32200153d62ae6b54f39dfda706ed7809857d09 100644 (file)
@@ -439,7 +439,7 @@ static unsigned int ip_conntrack_defrag(unsigned int hooknum,
 #endif
 
        /* Gather fragments. */
-       if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
+       if (ip_hdr(*pskb)->frag_off & htons(IP_MF | IP_OFFSET)) {
                *pskb = ip_ct_gather_frags(*pskb,
                                           hooknum == NF_IP_PRE_ROUTING ?
                                           IP_DEFRAG_CONNTRACK_IN :
index 25624e558562af2c5cba2a97a14f97898456c5ca..4cddc2951744ea39e6335c5a539eec87b61721d1 100644 (file)
@@ -94,7 +94,7 @@ static void mangle_contents(struct sk_buff *skb,
        unsigned char *data;
 
        BUG_ON(skb_is_nonlinear(skb));
-       data = (unsigned char *)skb->nh.iph + dataoff;
+       data = skb_network_header(skb) + dataoff;
 
        /* move post-replacement */
        memmove(data + match_offset + rep_len,
@@ -118,8 +118,8 @@ static void mangle_contents(struct sk_buff *skb,
        }
 
        /* fix IP hdr checksum information */
-       skb->nh.iph->tot_len = htons(skb->len);
-       ip_send_check(skb->nh.iph);
+       ip_hdr(skb)->tot_len = htons(skb->len);
+       ip_send_check(ip_hdr(skb));
 }
 
 /* Unusual, but possible case. */
@@ -173,7 +173,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
 
        SKB_LINEAR_ASSERT(*pskb);
 
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        tcph = (void *)iph + iph->ihl*4;
 
        oldlen = (*pskb)->len - iph->ihl*4;
@@ -227,7 +227,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
        int datalen, oldlen;
 
        /* UDP helpers might accidentally mangle the wrong packet */
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) +
                               match_offset + match_len)
                return 0;
@@ -240,7 +240,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
            && !enlarge_skb(pskb, rep_len - match_len))
                return 0;
 
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        udph = (void *)iph + iph->ihl*4;
 
        oldlen = (*pskb)->len - iph->ihl*4;
index 8b1e3388bd08ee6b1ac8ebed906f52dd10bf93a8..0d9444f9236b7e760e1358f3810b75a46ee19b45 100644 (file)
@@ -46,7 +46,7 @@ static int set_addr(struct sk_buff **pskb,
        buf.port = htons(port);
        addroff += dataoff;
 
-       if ((*pskb)->nh.iph->protocol == IPPROTO_TCP) {
+       if (ip_hdr(*pskb)->protocol == IPPROTO_TCP) {
                if (!ip_nat_mangle_tcp_packet(pskb, ct, ctinfo,
                                              addroff, sizeof(buf),
                                              (char *) &buf, sizeof(buf))) {
index 080eb1d922007490cb1ccd237a313cd369c72bf8..25415a91e023a1a495f841bac0be914578c79150 100644 (file)
@@ -158,7 +158,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb,
 
        if (hooknum == NF_IP_LOCAL_OUT
            && mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)
-               warn_if_extra_mangle((*pskb)->nh.iph->daddr,
+               warn_if_extra_mangle(ip_hdr(*pskb)->daddr,
                                     mr->range[0].min_ip);
 
        return ip_nat_setup_info(ct, &mr->range[0], hooknum);
index e41d0efae5159ff405326d5c40178b6f066a7932..025e045877896c4c76820adb201fbc9c1491991c 100644 (file)
@@ -1193,7 +1193,7 @@ static int snmp_translate(struct ip_conntrack *ct,
                          enum ip_conntrack_info ctinfo,
                          struct sk_buff **pskb)
 {
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
        u_int16_t udplen = ntohs(udph->len);
        u_int16_t paylen = udplen - sizeof(struct udphdr);
@@ -1234,7 +1234,7 @@ static int help(struct sk_buff **pskb,
 {
        int dir = CTINFO2DIR(ctinfo);
        unsigned int ret;
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        struct udphdr *udph = (struct udphdr *)((u_int32_t *)iph + iph->ihl);
 
        /* SNMP replies and originating SNMP traps get mangled */
index dbaaf78ff9a3fe5241d42871ac34dba6237cf0e0..32f7bf661fc8a343db0434aad8b7db6733874616 100644 (file)
@@ -97,7 +97,7 @@ ip_nat_fn(unsigned int hooknum,
 
        /* We never see fragments: conntrack defrags on pre-routing
           and local-out, and ip_nat_out protects post-routing. */
-       IP_NF_ASSERT(!((*pskb)->nh.iph->frag_off
+       IP_NF_ASSERT(!(ip_hdr(*pskb)->frag_off
                       & htons(IP_MF|IP_OFFSET)));
 
        ct = ip_conntrack_get(*pskb, &ctinfo);
@@ -109,7 +109,7 @@ ip_nat_fn(unsigned int hooknum,
                /* Exception: ICMP redirect to new connection (not in
                   hash table yet).  We must not let this through, in
                   case we're doing NAT to the same network. */
-               if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
+               if (ip_hdr(*pskb)->protocol == IPPROTO_ICMP) {
                        struct icmphdr _hdr, *hp;
 
                        hp = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
@@ -128,7 +128,7 @@ ip_nat_fn(unsigned int hooknum,
        switch (ctinfo) {
        case IP_CT_RELATED:
        case IP_CT_RELATED+IP_CT_IS_REPLY:
-               if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
+               if (ip_hdr(*pskb)->protocol == IPPROTO_ICMP) {
                        if (!ip_nat_icmp_reply_translation(ct, ctinfo,
                                                           hooknum, pskb))
                                return NF_DROP;
@@ -184,11 +184,11 @@ ip_nat_in(unsigned int hooknum,
          int (*okfn)(struct sk_buff *))
 {
        unsigned int ret;
-       __be32 daddr = (*pskb)->nh.iph->daddr;
+       __be32 daddr = ip_hdr(*pskb)->daddr;
 
        ret = ip_nat_fn(hooknum, pskb, in, out, okfn);
        if (ret != NF_DROP && ret != NF_STOLEN
-           && daddr != (*pskb)->nh.iph->daddr) {
+           && daddr != ip_hdr(*pskb)->daddr) {
                dst_release((*pskb)->dst);
                (*pskb)->dst = NULL;
        }
index f66966650212d78e5066b7823c36ae683e8f0b00..39ab8ae282e25fe15d602d0d18f3dd27a60ffdfc 100644 (file)
@@ -231,7 +231,7 @@ ipt_do_table(struct sk_buff **pskb,
        struct xt_table_info *private;
 
        /* Initialization */
-       ip = (*pskb)->nh.iph;
+       ip = ip_hdr(*pskb);
        datalen = (*pskb)->len - ip->ihl * 4;
        indev = in ? in->name : nulldevname;
        outdev = out ? out->name : nulldevname;
@@ -320,7 +320,7 @@ ipt_do_table(struct sk_buff **pskb,
                                        = 0x57acc001;
 #endif
                                /* Target might have changed stuff. */
-                               ip = (*pskb)->nh.iph;
+                               ip = ip_hdr(*pskb);
                                datalen = (*pskb)->len - ip->ihl * 4;
 
                                if (verdict == IPT_CONTINUE)
index 42b08029e86729edee953a0687c8c56485dedd1e..af5b82b8ceb791f5cd3a78e90af58281a9af4a64 100644 (file)
@@ -240,7 +240,7 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
 static inline u_int32_t
 clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
 {
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        unsigned long hashval;
        u_int16_t sport, dport;
        u_int16_t *ports;
@@ -328,7 +328,7 @@ target(struct sk_buff **pskb,
 
        /* special case: ICMP error handling. conntrack distinguishes between
         * error messages (RELATED) and information requests (see below) */
-       if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP
+       if (ip_hdr(*pskb)->protocol == IPPROTO_ICMP
            && (ctinfo == IP_CT_RELATED
                || ctinfo == IP_CT_RELATED+IP_CT_IS_REPLY))
                return XT_CONTINUE;
index 44daf9e1da35b3cd1b88df871009ba1aea04ca5b..97c0e53c8b22c1cf5577afeedc25c0a0389776cf 100644 (file)
@@ -30,13 +30,13 @@ MODULE_DESCRIPTION("iptables ECN modification module");
 static inline int
 set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
 {
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
 
        if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
                __u8 oldtos;
                if (!skb_make_writable(pskb, sizeof(struct iphdr)))
                        return 0;
-               iph = (*pskb)->nh.iph;
+               iph = ip_hdr(*pskb);
                oldtos = iph->tos;
                iph->tos &= ~IPT_ECN_IP_MASK;
                iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
@@ -66,7 +66,7 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
 
        if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
                return 0;
-       tcph = (void *)(*pskb)->nh.iph + ip_hdrlen(*pskb);
+       tcph = (void *)ip_hdr(*pskb) + ip_hdrlen(*pskb);
 
        oldval = ((__be16 *)tcph)[6];
        if (einfo->operation & IPT_ECN_OP_SET_ECE)
@@ -94,7 +94,7 @@ target(struct sk_buff **pskb,
                        return NF_DROP;
 
        if (einfo->operation & (IPT_ECN_OP_SET_ECE | IPT_ECN_OP_SET_CWR)
-           && (*pskb)->nh.iph->protocol == IPPROTO_TCP)
+           && ip_hdr(*pskb)->protocol == IPPROTO_TCP)
                if (!set_ect_tcp(pskb, einfo))
                        return NF_DROP;
 
index fd7aaa347cd8aac4332066af2c9edd9123ca3725..d03f165722da5ae4b807e8d03329bf6792fd55cd 100644 (file)
@@ -75,9 +75,9 @@ target(struct sk_buff **pskb,
        netmask = ~(mr->range[0].min_ip ^ mr->range[0].max_ip);
 
        if (hooknum == NF_IP_PRE_ROUTING || hooknum == NF_IP_LOCAL_OUT)
-               new_ip = (*pskb)->nh.iph->daddr & ~netmask;
+               new_ip = ip_hdr(*pskb)->daddr & ~netmask;
        else
-               new_ip = (*pskb)->nh.iph->saddr & ~netmask;
+               new_ip = ip_hdr(*pskb)->saddr & ~netmask;
        new_ip |= mr->range[0].min_ip & netmask;
 
        newrange = ((struct ip_nat_range)
index 01c04f0e5c910d4d0fab580863c36a05fd4963f8..1399e7c183baa13582f360fcb1a26952c628ed30 100644 (file)
@@ -43,6 +43,7 @@ MODULE_DESCRIPTION("iptables REJECT target module");
 static void send_reset(struct sk_buff *oldskb, int hook)
 {
        struct sk_buff *nskb;
+       struct iphdr *niph;
        struct tcphdr _otcph, *oth, *tcph;
        __be16 tmp_port;
        __be32 tmp_addr;
@@ -50,7 +51,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
        unsigned int addr_type;
 
        /* IP header checks: fragment. */
-       if (oldskb->nh.iph->frag_off & htons(IP_OFFSET))
+       if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
                return;
 
        oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb),
@@ -86,9 +87,10 @@ static void send_reset(struct sk_buff *oldskb, int hook)
        tcph = (struct tcphdr *)(skb_network_header(nskb) + ip_hdrlen(nskb));
 
        /* Swap source and dest */
-       tmp_addr = nskb->nh.iph->saddr;
-       nskb->nh.iph->saddr = nskb->nh.iph->daddr;
-       nskb->nh.iph->daddr = tmp_addr;
+       niph = ip_hdr(nskb);
+       tmp_addr = niph->saddr;
+       niph->saddr = niph->daddr;
+       niph->daddr = tmp_addr;
        tmp_port = tcph->source;
        tcph->source = tcph->dest;
        tcph->dest = tmp_port;
@@ -96,7 +98,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
        /* Truncate to length (no data) */
        tcph->doff = sizeof(struct tcphdr)/4;
        skb_trim(nskb, ip_hdrlen(nskb) + sizeof(struct tcphdr));
-       nskb->nh.iph->tot_len = htons(nskb->len);
+       niph->tot_len = htons(nskb->len);
 
        if (tcph->ack) {
                needs_ack = 0;
@@ -121,14 +123,13 @@ static void send_reset(struct sk_buff *oldskb, int hook)
        /* Adjust TCP checksum */
        tcph->check = 0;
        tcph->check = tcp_v4_check(sizeof(struct tcphdr),
-                                  nskb->nh.iph->saddr,
-                                  nskb->nh.iph->daddr,
+                                  niph->saddr, niph->daddr,
                                   csum_partial((char *)tcph,
                                                sizeof(struct tcphdr), 0));
 
        /* Set DF, id = 0 */
-       nskb->nh.iph->frag_off = htons(IP_DF);
-       nskb->nh.iph->id = 0;
+       niph->frag_off = htons(IP_DF);
+       niph->id = 0;
 
        addr_type = RTN_UNSPEC;
        if (hook != NF_IP_FORWARD
@@ -144,12 +145,11 @@ static void send_reset(struct sk_buff *oldskb, int hook)
        nskb->ip_summed = CHECKSUM_NONE;
 
        /* Adjust IP TTL */
-       nskb->nh.iph->ttl = dst_metric(nskb->dst, RTAX_HOPLIMIT);
+       niph->ttl = dst_metric(nskb->dst, RTAX_HOPLIMIT);
 
        /* Adjust IP checksum */
-       nskb->nh.iph->check = 0;
-       nskb->nh.iph->check = ip_fast_csum(skb_network_header(nskb),
-                                          nskb->nh.iph->ihl);
+       niph->check = 0;
+       niph->check = ip_fast_csum(skb_network_header(nskb), niph->ihl);
 
        /* "Never happens" */
        if (nskb->len > dst_mtu(nskb->dst))
index cedf9f7d9d6ef650fbeef90dc2609f7d45f8836f..0ad02f2498375d29be101ce2eda06af686a30a11 100644 (file)
@@ -29,13 +29,13 @@ target(struct sk_buff **pskb,
        const void *targinfo)
 {
        const struct ipt_tos_target_info *tosinfo = targinfo;
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
 
        if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) {
                __u8 oldtos;
                if (!skb_make_writable(pskb, sizeof(struct iphdr)))
                        return NF_DROP;
-               iph = (*pskb)->nh.iph;
+               iph = ip_hdr(*pskb);
                oldtos = iph->tos;
                iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
                nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
index 64be31c22ba9eb4aac423865fc640e835cca86fb..a991ec7bd4e7207e9c7a15c937ca60fac1fa6a51 100644 (file)
@@ -32,7 +32,7 @@ ipt_ttl_target(struct sk_buff **pskb,
        if (!skb_make_writable(pskb, (*pskb)->len))
                return NF_DROP;
 
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
 
        switch (info->mode) {
                case IPT_TTL_SET:
index cfa0472617f604c89f7e9cb87da40ae937c91632..a652a14515526f651a5bc8d67176ed20bfb254f7 100644 (file)
@@ -33,7 +33,7 @@ static int match(const struct sk_buff *skb,
                 int offset, unsigned int protoff, int *hotdrop)
 {
        const struct ipt_addrtype_info *info = matchinfo;
-       const struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
        int ret = 1;
 
        if (info->source)
index b8ade3cc775728c2ab5fd328735c388363fa9d16..3b4ca0c5c12142c539da2d8a1886a861aca173d6 100644 (file)
@@ -27,7 +27,7 @@ MODULE_LICENSE("GPL");
 static inline int match_ip(const struct sk_buff *skb,
                           const struct ipt_ecn_info *einfo)
 {
-       return ((skb->nh.iph->tos&IPT_ECN_IP_MASK) == einfo->ip_ect);
+       return (ip_hdr(skb)->tos & IPT_ECN_IP_MASK) == einfo->ip_ect;
 }
 
 static inline int match_tcp(const struct sk_buff *skb,
@@ -80,7 +80,7 @@ static int match(const struct sk_buff *skb,
                        return 0;
 
        if (info->operation & (IPT_ECN_OP_MATCH_ECE|IPT_ECN_OP_MATCH_CWR)) {
-               if (skb->nh.iph->protocol != IPPROTO_TCP)
+               if (ip_hdr(skb)->protocol != IPPROTO_TCP)
                        return 0;
                if (!match_tcp(skb, info, hotdrop))
                        return 0;
index bc5d5e6091e476bf58fb79bfe886a1e44f876f71..33af9e9408875d1aa4d237e9db73a92a5d185bd9 100644 (file)
@@ -32,7 +32,7 @@ match(const struct sk_buff *skb,
       int offset, unsigned int protoff, int *hotdrop)
 {
        const struct ipt_iprange_info *info = matchinfo;
-       const struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
 
        if (info->flags & IPRANGE_SRC) {
                if (((ntohl(iph->saddr) < ntohl(info->src.min_ip))
index aecb9c48e15252ef4fe04fb8bb3c1d970dc47dda..15a9e8bbb7cc65d35ba6c85bebd5658bfbd791fc 100644 (file)
@@ -183,11 +183,11 @@ ipt_recent_match(const struct sk_buff *skb,
        int ret = info->invert;
 
        if (info->side == IPT_RECENT_DEST)
-               addr = skb->nh.iph->daddr;
+               addr = ip_hdr(skb)->daddr;
        else
-               addr = skb->nh.iph->saddr;
+               addr = ip_hdr(skb)->saddr;
 
-       ttl = skb->nh.iph->ttl;
+       ttl = ip_hdr(skb)->ttl;
        /* use TTL as seen before forwarding */
        if (out && !skb->sk)
                ttl++;
index 5d33b51d49d8408e51f988f22864c8ec5d5a29df..d314844af12b080991e082a108d83be27d426a41 100644 (file)
@@ -30,7 +30,7 @@ match(const struct sk_buff *skb,
 {
        const struct ipt_tos_info *info = matchinfo;
 
-       return (skb->nh.iph->tos == info->tos) ^ info->invert;
+       return (ip_hdr(skb)->tos == info->tos) ^ info->invert;
 }
 
 static struct xt_match tos_match = {
index 1eca9f40037493b69a025f16f016d070c536b91d..9615c04a2fc6fa2a8845b5e260a3d4323603c393 100644 (file)
@@ -26,19 +26,20 @@ static int match(const struct sk_buff *skb,
                 int offset, unsigned int protoff, int *hotdrop)
 {
        const struct ipt_ttl_info *info = matchinfo;
+       const u8 ttl = ip_hdr(skb)->ttl;
 
        switch (info->mode) {
                case IPT_TTL_EQ:
-                       return (skb->nh.iph->ttl == info->ttl);
+                       return (ttl == info->ttl);
                        break;
                case IPT_TTL_NE:
-                       return (!(skb->nh.iph->ttl == info->ttl));
+                       return (!(ttl == info->ttl));
                        break;
                case IPT_TTL_LT:
-                       return (skb->nh.iph->ttl < info->ttl);
+                       return (ttl < info->ttl);
                        break;
                case IPT_TTL_GT:
-                       return (skb->nh.iph->ttl > info->ttl);
+                       return (ttl > info->ttl);
                        break;
                default:
                        printk(KERN_WARNING "ipt_ttl: unknown mode %d\n",
index 6cc3245f676af73142f3a37bfa8d2f7cbdf69c60..26e60fbe7ee0ab9205010e6ab9101a213469d480 100644 (file)
@@ -131,6 +131,7 @@ ipt_local_hook(unsigned int hook,
                   int (*okfn)(struct sk_buff *))
 {
        unsigned int ret;
+       const struct iphdr *iph;
        u_int8_t tos;
        __be32 saddr, daddr;
        u_int32_t mark;
@@ -145,19 +146,23 @@ ipt_local_hook(unsigned int hook,
 
        /* Save things which could affect route */
        mark = (*pskb)->mark;
-       saddr = (*pskb)->nh.iph->saddr;
-       daddr = (*pskb)->nh.iph->daddr;
-       tos = (*pskb)->nh.iph->tos;
+       iph = ip_hdr(*pskb);
+       saddr = iph->saddr;
+       daddr = iph->daddr;
+       tos = iph->tos;
 
        ret = ipt_do_table(pskb, hook, in, out, &packet_mangler);
        /* Reroute for ANY change. */
-       if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE
-           && ((*pskb)->nh.iph->saddr != saddr
-               || (*pskb)->nh.iph->daddr != daddr
-               || (*pskb)->mark != mark
-               || (*pskb)->nh.iph->tos != tos))
-               if (ip_route_me_harder(pskb, RTN_UNSPEC))
-                       ret = NF_DROP;
+       if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE) {
+               iph = ip_hdr(*pskb);
+
+               if (iph->saddr != saddr ||
+                   iph->daddr != daddr ||
+                   (*pskb)->mark != mark ||
+                   iph->tos != tos)
+                       if (ip_route_me_harder(pskb, RTN_UNSPEC))
+                               ret = NF_DROP;
+       }
 
        return ret;
 }
index fa14eb77f9b687f6cbe7f069757d5a50d594234a..d52ca0c1ce8dd65ba8000879a1c9661930f2b4bd 100644 (file)
@@ -87,7 +87,7 @@ nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
        local_bh_enable();
 
        if (skb)
-               ip_send_check(skb->nh.iph);
+               ip_send_check(ip_hdr(skb));
 
        return skb;
 }
@@ -97,16 +97,16 @@ ipv4_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
             u_int8_t *protonum)
 {
        /* Never happen */
-       if ((*pskb)->nh.iph->frag_off & htons(IP_OFFSET)) {
+       if (ip_hdr(*pskb)->frag_off & htons(IP_OFFSET)) {
                if (net_ratelimit()) {
                        printk(KERN_ERR "ipv4_prepare: Frag of proto %u (hook=%u)\n",
-                       (*pskb)->nh.iph->protocol, hooknum);
+                       ip_hdr(*pskb)->protocol, hooknum);
                }
                return -NF_DROP;
        }
 
        *dataoff = skb_network_offset(*pskb) + ip_hdrlen(*pskb);
-       *protonum = (*pskb)->nh.iph->protocol;
+       *protonum = ip_hdr(*pskb)->protocol;
 
        return NF_ACCEPT;
 }
@@ -170,7 +170,7 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
 #endif
 
        /* Gather fragments. */
-       if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
+       if (ip_hdr(*pskb)->frag_off & htons(IP_MF | IP_OFFSET)) {
                *pskb = nf_ct_ipv4_gather_frags(*pskb,
                                                hooknum == NF_IP_PRE_ROUTING ?
                                                IP_DEFRAG_CONNTRACK_IN :
index 2eb3832db3a4323fccdb63d47b44a14dc44c0f2d..3c58fea0d391b306f96da82a7aa04997efa2a568 100644 (file)
@@ -44,7 +44,7 @@ static int set_addr(struct sk_buff **pskb,
        buf.port = port;
        addroff += dataoff;
 
-       if ((*pskb)->nh.iph->protocol == IPPROTO_TCP) {
+       if (ip_hdr(*pskb)->protocol == IPPROTO_TCP) {
                if (!nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
                                              addroff, sizeof(buf),
                                              (char *) &buf, sizeof(buf))) {
index 723302afd84073f9e38315a23b2aee47ec80d8e9..c2c92ff1278189371307cef1db000243b08a171d 100644 (file)
@@ -87,7 +87,7 @@ static void mangle_contents(struct sk_buff *skb,
        unsigned char *data;
 
        BUG_ON(skb_is_nonlinear(skb));
-       data = (unsigned char *)skb->nh.iph + dataoff;
+       data = skb_network_header(skb) + dataoff;
 
        /* move post-replacement */
        memmove(data + match_offset + rep_len,
@@ -111,8 +111,8 @@ static void mangle_contents(struct sk_buff *skb,
        }
 
        /* fix IP hdr checksum information */
-       skb->nh.iph->tot_len = htons(skb->len);
-       ip_send_check(skb->nh.iph);
+       ip_hdr(skb)->tot_len = htons(skb->len);
+       ip_send_check(ip_hdr(skb));
 }
 
 /* Unusual, but possible case. */
@@ -166,7 +166,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff **pskb,
 
        SKB_LINEAR_ASSERT(*pskb);
 
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        tcph = (void *)iph + iph->ihl*4;
 
        oldlen = (*pskb)->len - iph->ihl*4;
@@ -221,7 +221,7 @@ nf_nat_mangle_udp_packet(struct sk_buff **pskb,
        int datalen, oldlen;
 
        /* UDP helpers might accidentally mangle the wrong packet */
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) +
                               match_offset + match_len)
                return 0;
@@ -234,7 +234,7 @@ nf_nat_mangle_udp_packet(struct sk_buff **pskb,
            !enlarge_skb(pskb, rep_len - match_len))
                return 0;
 
-       iph = (*pskb)->nh.iph;
+       iph = ip_hdr(*pskb);
        udph = (void *)iph + iph->ihl*4;
 
        oldlen = (*pskb)->len - iph->ihl*4;
index 147a4370cf03e43f744600c5c3773454b54b5e68..2a283397a8b6084ba33ac0264c99575e7ac44785 100644 (file)
@@ -191,7 +191,7 @@ static unsigned int ipt_dnat_target(struct sk_buff **pskb,
 
        if (hooknum == NF_IP_LOCAL_OUT &&
            mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)
-               warn_if_extra_mangle((*pskb)->nh.iph->daddr,
+               warn_if_extra_mangle(ip_hdr(*pskb)->daddr,
                                     mr->range[0].min_ip);
 
        return nf_nat_setup_info(ct, &mr->range[0], hooknum);
index ce5c4939a6ee240d764e3e593429dae1523edb8a..0cc0d97585df3530a501152b869bea43823a3718 100644 (file)
@@ -1194,7 +1194,7 @@ static int snmp_translate(struct nf_conn *ct,
                          enum ip_conntrack_info ctinfo,
                          struct sk_buff **pskb)
 {
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
        u_int16_t udplen = ntohs(udph->len);
        u_int16_t paylen = udplen - sizeof(struct udphdr);
@@ -1235,7 +1235,7 @@ static int help(struct sk_buff **pskb, unsigned int protoff,
 {
        int dir = CTINFO2DIR(ctinfo);
        unsigned int ret;
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        struct udphdr *udph = (struct udphdr *)((u_int32_t *)iph + iph->ihl);
 
        /* SNMP replies and originating SNMP traps get mangled */
index 61ca272165a1326e27e901a96ecf738715cd36a2..64bbed2ba7808c494281f9940ff227928307634e 100644 (file)
@@ -86,8 +86,7 @@ nf_nat_fn(unsigned int hooknum,
 
        /* We never see fragments: conntrack defrags on pre-routing
           and local-out, and nf_nat_out protects post-routing. */
-       NF_CT_ASSERT(!((*pskb)->nh.iph->frag_off
-                      & htons(IP_MF|IP_OFFSET)));
+       NF_CT_ASSERT(!(ip_hdr(*pskb)->frag_off & htons(IP_MF | IP_OFFSET)));
 
        ct = nf_ct_get(*pskb, &ctinfo);
        /* Can't track?  It's not due to stress, or conntrack would
@@ -98,7 +97,7 @@ nf_nat_fn(unsigned int hooknum,
                /* Exception: ICMP redirect to new connection (not in
                   hash table yet).  We must not let this through, in
                   case we're doing NAT to the same network. */
-               if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
+               if (ip_hdr(*pskb)->protocol == IPPROTO_ICMP) {
                        struct icmphdr _hdr, *hp;
 
                        hp = skb_header_pointer(*pskb, ip_hdrlen(*pskb),
@@ -121,7 +120,7 @@ nf_nat_fn(unsigned int hooknum,
        switch (ctinfo) {
        case IP_CT_RELATED:
        case IP_CT_RELATED+IP_CT_IS_REPLY:
-               if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
+               if (ip_hdr(*pskb)->protocol == IPPROTO_ICMP) {
                        if (!nf_nat_icmp_reply_translation(ct, ctinfo,
                                                           hooknum, pskb))
                                return NF_DROP;
@@ -176,11 +175,11 @@ nf_nat_in(unsigned int hooknum,
          int (*okfn)(struct sk_buff *))
 {
        unsigned int ret;
-       __be32 daddr = (*pskb)->nh.iph->daddr;
+       __be32 daddr = ip_hdr(*pskb)->daddr;
 
        ret = nf_nat_fn(hooknum, pskb, in, out, okfn);
        if (ret != NF_DROP && ret != NF_STOLEN &&
-           daddr != (*pskb)->nh.iph->daddr) {
+           daddr != ip_hdr(*pskb)->daddr) {
                dst_release((*pskb)->dst);
                (*pskb)->dst = NULL;
        }
index c3757bb270ca710733eeecda3949d19c6352876b..ac57afa7c3163f185f95f96e2e04f5367bb638f3 100644 (file)
@@ -292,7 +292,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
        skb->dst = dst_clone(&rt->u.dst);
 
        skb_reset_network_header(skb);
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        skb_put(skb, length);
 
        skb->ip_summed = CHECKSUM_NONE;
@@ -615,7 +615,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        /* Copy the address. */
        if (sin) {
                sin->sin_family = AF_INET;
-               sin->sin_addr.s_addr = skb->nh.iph->saddr;
+               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
                sin->sin_port = 0;
                memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
        }
index e50ad7dbbde87894c448173475aaf6c29d9b65a8..58417393dec1d8c323b522062dcf4f05b326efce 100644 (file)
@@ -1519,7 +1519,7 @@ static void ipv4_link_failure(struct sk_buff *skb)
 static int ip_rt_bug(struct sk_buff *skb)
 {
        printk(KERN_DEBUG "ip_rt_bug: %u.%u.%u.%u -> %u.%u.%u.%u, %s\n",
-               NIPQUAD(skb->nh.iph->saddr), NIPQUAD(skb->nh.iph->daddr),
+               NIPQUAD(ip_hdr(skb)->saddr), NIPQUAD(ip_hdr(skb)->daddr),
                skb->dev ? skb->dev->name : "?");
        kfree_skb(skb);
        return 0;
@@ -2134,7 +2134,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
                rcu_read_lock();
                if ((in_dev = __in_dev_get_rcu(dev)) != NULL) {
                        int our = ip_check_mc(in_dev, daddr, saddr,
-                               skb->nh.iph->protocol);
+                               ip_hdr(skb)->protocol);
                        if (our
 #ifdef CONFIG_IP_MROUTE
                            || (!LOCAL_MCAST(daddr) && IN_DEV_MFORWARD(in_dev))
@@ -2751,7 +2751,7 @@ int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg)
        skb_reset_network_header(skb);
 
        /* Bugfix: need to give ip_route_input enough of an IP header to not gag. */
-       skb->nh.iph->protocol = IPPROTO_ICMP;
+       ip_hdr(skb)->protocol = IPPROTO_ICMP;
        skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
 
        src = tb[RTA_SRC] ? nla_get_be32(tb[RTA_SRC]) : 0;
index 33016cc90f0b8a7add18555666a010f87bc550ab..261607178491ce0c7e885e0e570739f81937af91 100644 (file)
@@ -138,7 +138,7 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
 
        NET_INC_STATS_BH(LINUX_MIB_SYNCOOKIESSENT);
 
-       return secure_tcp_syn_cookie(skb->nh.iph->saddr, skb->nh.iph->daddr,
+       return secure_tcp_syn_cookie(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
                                     skb->h.th->source, skb->h.th->dest,
                                     ntohl(skb->h.th->seq),
                                     jiffies / (HZ * 60), mssind);
@@ -162,7 +162,7 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
 
        seq = ntohl(skb->h.th->seq)-1;
        mssind = check_tcp_syn_cookie(cookie,
-                                     skb->nh.iph->saddr, skb->nh.iph->daddr,
+                                     ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
                                      skb->h.th->source, skb->h.th->dest,
                                      seq, jiffies / (HZ * 60), COUNTER_TRIES);
 
@@ -224,8 +224,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
        treq->snt_isn           = cookie;
        req->mss                = mss;
        ireq->rmt_port          = skb->h.th->source;
-       ireq->loc_addr          = skb->nh.iph->daddr;
-       ireq->rmt_addr          = skb->nh.iph->saddr;
+       ireq->loc_addr          = ip_hdr(skb)->daddr;
+       ireq->rmt_addr          = ip_hdr(skb)->saddr;
        ireq->opt               = NULL;
 
        /* We throwed the options of the initial SYN away, so we hope
index 3326681b8429352597e5145232c5aee6a84a6b20..3a86d6b887acbf1617756c6918b60a9569c7a3c7 100644 (file)
@@ -125,8 +125,8 @@ void tcp_unhash(struct sock *sk)
 
 static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb)
 {
-       return secure_tcp_sequence_number(skb->nh.iph->daddr,
-                                         skb->nh.iph->saddr,
+       return secure_tcp_sequence_number(ip_hdr(skb)->daddr,
+                                         ip_hdr(skb)->saddr,
                                          skb->h.th->dest,
                                          skb->h.th->source);
 }
@@ -515,13 +515,13 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
 
 int tcp_v4_gso_send_check(struct sk_buff *skb)
 {
-       struct iphdr *iph;
+       const struct iphdr *iph;
        struct tcphdr *th;
 
        if (!pskb_may_pull(skb, sizeof(*th)))
                return -EINVAL;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        th = skb->h.th;
 
        th->check = 0;
@@ -585,7 +585,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
        arg.iov[0].iov_len  = sizeof(rep.th);
 
 #ifdef CONFIG_TCP_MD5SIG
-       key = sk ? tcp_v4_md5_do_lookup(sk, skb->nh.iph->daddr) : NULL;
+       key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr) : NULL;
        if (key) {
                rep.opt[0] = htonl((TCPOPT_NOP << 24) |
                                   (TCPOPT_NOP << 16) |
@@ -597,14 +597,14 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
 
                tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[1],
                                        key,
-                                       skb->nh.iph->daddr,
-                                       skb->nh.iph->saddr,
+                                       ip_hdr(skb)->daddr,
+                                       ip_hdr(skb)->saddr,
                                        &rep.th, IPPROTO_TCP,
                                        arg.iov[0].iov_len);
        }
 #endif
-       arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr,
-                                     skb->nh.iph->saddr, /* XXX */
+       arg.csum = csum_tcpudp_nofold(ip_hdr(skb)->daddr,
+                                     ip_hdr(skb)->saddr, /* XXX */
                                      sizeof(struct tcphdr), IPPROTO_TCP, 0);
        arg.csumoffset = offsetof(struct tcphdr, check) / 2;
 
@@ -670,7 +670,7 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk,
         * skb->sk) holds true, but we program defensively.
         */
        if (!twsk && skb->sk) {
-               key = tcp_v4_md5_do_lookup(skb->sk, skb->nh.iph->daddr);
+               key = tcp_v4_md5_do_lookup(skb->sk, ip_hdr(skb)->daddr);
        } else if (twsk && twsk->tw_md5_keylen) {
                tw_key.key = twsk->tw_md5_key;
                tw_key.keylen = twsk->tw_md5_keylen;
@@ -690,14 +690,14 @@ static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk,
 
                tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[offset],
                                        key,
-                                       skb->nh.iph->daddr,
-                                       skb->nh.iph->saddr,
+                                       ip_hdr(skb)->daddr,
+                                       ip_hdr(skb)->saddr,
                                        &rep.th, IPPROTO_TCP,
                                        arg.iov[0].iov_len);
        }
 #endif
-       arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr,
-                                     skb->nh.iph->saddr, /* XXX */
+       arg.csum = csum_tcpudp_nofold(ip_hdr(skb)->daddr,
+                                     ip_hdr(skb)->saddr, /* XXX */
                                      arg.iov[0].iov_len, IPPROTO_TCP, 0);
        arg.csumoffset = offsetof(struct tcphdr, check) / 2;
 
@@ -1133,7 +1133,7 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb)
         */
        __u8 *hash_location = NULL;
        struct tcp_md5sig_key *hash_expected;
-       struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
        struct tcphdr *th = skb->h.th;
        int length = (th->doff << 2) - sizeof(struct tcphdr);
        int genhash;
@@ -1251,8 +1251,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
        struct inet_request_sock *ireq;
        struct tcp_options_received tmp_opt;
        struct request_sock *req;
-       __be32 saddr = skb->nh.iph->saddr;
-       __be32 daddr = skb->nh.iph->daddr;
+       __be32 saddr = ip_hdr(skb)->saddr;
+       __be32 daddr = ip_hdr(skb)->daddr;
        __u32 isn = TCP_SKB_CB(skb)->when;
        struct dst_entry *dst = NULL;
 #ifdef CONFIG_SYN_COOKIES
@@ -1439,7 +1439,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
        newinet->opt          = ireq->opt;
        ireq->opt             = NULL;
        newinet->mc_index     = inet_iif(skb);
-       newinet->mc_ttl       = skb->nh.iph->ttl;
+       newinet->mc_ttl       = ip_hdr(skb)->ttl;
        inet_csk(newsk)->icsk_ext_hdr_len = 0;
        if (newinet->opt)
                inet_csk(newsk)->icsk_ext_hdr_len = newinet->opt->optlen;
@@ -1482,7 +1482,7 @@ exit:
 static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
 {
        struct tcphdr *th = skb->h.th;
-       struct iphdr *iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
        struct sock *nsk;
        struct request_sock **prev;
        /* Find possible connection requests. */
@@ -1491,9 +1491,8 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
        if (req)
                return tcp_check_req(sk, skb, req, prev);
 
-       nsk = inet_lookup_established(&tcp_hashinfo, skb->nh.iph->saddr,
-                                     th->source, skb->nh.iph->daddr,
-                                     th->dest, inet_iif(skb));
+       nsk = inet_lookup_established(&tcp_hashinfo, iph->saddr, th->source,
+                                     iph->daddr, th->dest, inet_iif(skb));
 
        if (nsk) {
                if (nsk->sk_state != TCP_TIME_WAIT) {
@@ -1513,15 +1512,17 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
 
 static __sum16 tcp_v4_checksum_init(struct sk_buff *skb)
 {
+       const struct iphdr *iph = ip_hdr(skb);
+
        if (skb->ip_summed == CHECKSUM_COMPLETE) {
-               if (!tcp_v4_check(skb->len, skb->nh.iph->saddr,
-                                 skb->nh.iph->daddr, skb->csum)) {
+               if (!tcp_v4_check(skb->len, iph->saddr,
+                                 iph->daddr, skb->csum)) {
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
                        return 0;
                }
        }
 
-       skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr, skb->nh.iph->daddr,
+       skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
                                       skb->len, IPPROTO_TCP, 0);
 
        if (skb->len <= 76) {
@@ -1610,6 +1611,7 @@ csum_err:
 
 int tcp_v4_rcv(struct sk_buff *skb)
 {
+       const struct iphdr *iph;
        struct tcphdr *th;
        struct sock *sk;
        int ret;
@@ -1639,18 +1641,17 @@ int tcp_v4_rcv(struct sk_buff *skb)
                goto bad_packet;
 
        th = skb->h.th;
+       iph = ip_hdr(skb);
        TCP_SKB_CB(skb)->seq = ntohl(th->seq);
        TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
                                    skb->len - th->doff * 4);
        TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
        TCP_SKB_CB(skb)->when    = 0;
-       TCP_SKB_CB(skb)->flags   = skb->nh.iph->tos;
+       TCP_SKB_CB(skb)->flags   = iph->tos;
        TCP_SKB_CB(skb)->sacked  = 0;
 
-       sk = __inet_lookup(&tcp_hashinfo, skb->nh.iph->saddr, th->source,
-                          skb->nh.iph->daddr, th->dest,
-                          inet_iif(skb));
-
+       sk = __inet_lookup(&tcp_hashinfo, iph->saddr, th->source,
+                          iph->daddr, th->dest, inet_iif(skb));
        if (!sk)
                goto no_tcp_socket;
 
@@ -1724,8 +1725,7 @@ do_time_wait:
        switch (tcp_timewait_state_process(inet_twsk(sk), skb, th)) {
        case TCP_TW_SYN: {
                struct sock *sk2 = inet_lookup_listener(&tcp_hashinfo,
-                                                       skb->nh.iph->daddr,
-                                                       th->dest,
+                                                       iph->daddr, th->dest,
                                                        inet_iif(skb));
                if (sk2) {
                        inet_twsk_deschedule(inet_twsk(sk), &tcp_death_row);
index 1bbf5510cf3a9185cbb2d64a05b8e9cf4e49d1ba..b4cad50c18e903e7656dadf1da11ad27965fb007 100644 (file)
@@ -867,7 +867,7 @@ try_again:
        {
                sin->sin_family = AF_INET;
                sin->sin_port = skb->h.uh->source;
-               sin->sin_addr.s_addr = skb->nh.iph->saddr;
+               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
                memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
        }
        if (inet->cmsg_flags)
@@ -990,7 +990,7 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
                return 0;
 
        /* Now we can update and verify the packet length... */
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        iphlen = iph->ihl << 2;
        iph->tot_len = htons(ntohs(iph->tot_len) - len);
        if (skb->len < iphlen + len) {
@@ -1168,6 +1168,7 @@ static int __udp4_lib_mcast_deliver(struct sk_buff *skb,
 static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
                                 int proto)
 {
+       const struct iphdr *iph;
        int err;
 
        UDP_SKB_CB(skb)->partial_cov = 0;
@@ -1179,16 +1180,16 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
                        return err;
        }
 
+       iph = ip_hdr(skb);
        if (uh->check == 0) {
                skb->ip_summed = CHECKSUM_UNNECESSARY;
        } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
-              if (!csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
-                                     skb->len, proto, skb->csum))
+              if (!csum_tcpudp_magic(iph->saddr, iph->daddr, skb->len,
+                                     proto, skb->csum))
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
        }
        if (skb->ip_summed != CHECKSUM_UNNECESSARY)
-               skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr,
-                                              skb->nh.iph->daddr,
+               skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
                                               skb->len, proto, 0);
        /* Probably, we should checksum udp header (it should be in cache
         * in any case) and data in tiny packets (< rx copybreak).
@@ -1208,8 +1209,8 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
        struct udphdr *uh = skb->h.uh;
        unsigned short ulen;
        struct rtable *rt = (struct rtable*)skb->dst;
-       __be32 saddr = skb->nh.iph->saddr;
-       __be32 daddr = skb->nh.iph->daddr;
+       __be32 saddr = ip_hdr(skb)->saddr;
+       __be32 daddr = ip_hdr(skb)->daddr;
 
        /*
         *  Validate the packet.
index d89969c502ddac2dc0dbb99807ae05c33a58f354..5ceca951d73f4fc4964d802ce68aac833c463904 100644 (file)
@@ -28,7 +28,7 @@ static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32
        switch (nexthdr) {
        case IPPROTO_IPIP:
        case IPPROTO_IPV6:
-               *spi = skb->nh.iph->saddr;
+               *spi = ip_hdr(skb)->saddr;
                *seq = 0;
                return 0;
        }
@@ -39,9 +39,9 @@ static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32
 #ifdef CONFIG_NETFILTER
 static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb)
 {
-       struct iphdr *iph = skb->nh.iph;
-
        if (skb->dst == NULL) {
+               const struct iphdr *iph = ip_hdr(skb);
+
                if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
                                   skb->dev))
                        goto drop;
@@ -55,18 +55,18 @@ drop:
 
 int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
 {
-       int err;
        __be32 spi, seq;
        struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH];
        struct xfrm_state *x;
        int xfrm_nr = 0;
        int decaps = 0;
+       int err = xfrm4_parse_spi(skb, ip_hdr(skb)->protocol, &spi, &seq);
 
-       if ((err = xfrm4_parse_spi(skb, skb->nh.iph->protocol, &spi, &seq)) != 0)
+       if (err != 0)
                goto drop;
 
        do {
-               struct iphdr *iph = skb->nh.iph;
+               const struct iphdr *iph = ip_hdr(skb);
 
                if (xfrm_nr == XFRM_MAX_DEPTH)
                        goto drop;
@@ -113,7 +113,8 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
                        break;
                }
 
-               if ((err = xfrm_parse_spi(skb, skb->nh.iph->protocol, &spi, &seq)) < 0)
+               err = xfrm_parse_spi(skb, ip_hdr(skb)->protocol, &spi, &seq);
+               if (err < 0)
                        goto drop;
        } while (!err);
 
@@ -147,14 +148,14 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
        } else {
 #ifdef CONFIG_NETFILTER
                __skb_push(skb, skb->data - skb_network_header(skb));
-               skb->nh.iph->tot_len = htons(skb->len);
-               ip_send_check(skb->nh.iph);
+               ip_hdr(skb)->tot_len = htons(skb->len);
+               ip_send_check(ip_hdr(skb));
 
                NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, skb->dev, NULL,
                        xfrm4_rcv_encap_finish);
                return 0;
 #else
-               return -skb->nh.iph->protocol;
+               return -ip_hdr(skb)->protocol;
 #endif
        }
 
index 505fca034a1ff2fc10aa718f7700acd31a0a0364..9e5ba12c6c7529158da629919893fe9e72a97543 100644 (file)
@@ -32,8 +32,8 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
        struct iphdr *iph, *top_iph = NULL;
        int hdrlen, optlen;
 
-       iph = skb->nh.iph;
-       skb->h.ipiph = iph;
+       iph = ip_hdr(skb);
+       skb->h.raw = skb->nh.raw;
 
        hdrlen = 0;
        optlen = iph->ihl * 4 - sizeof(*iph);
@@ -42,7 +42,7 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 
        skb_push(skb, x->props.header_len + hdrlen);
        skb_reset_network_header(skb);
-       top_iph = skb->nh.iph;
+       top_iph = ip_hdr(skb);
        skb->h.raw += sizeof(*iph) - hdrlen;
 
        memmove(top_iph, iph, sizeof(*iph));
@@ -70,7 +70,7 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 
 static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb)
 {
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        int phlen = 0;
        int optlen = 0;
        __u8 ph_nexthdr = 0, protocol = 0;
@@ -102,7 +102,7 @@ static int xfrm4_beet_input(struct xfrm_state *x, struct sk_buff *skb)
        skb->h.raw = skb->data + (phlen + optlen);
        skb->data = skb->h.raw;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        iph->ihl = (sizeof(*iph) + optlen) / 4;
        iph->tot_len = htons(skb->len + iph->ihl * 4);
        iph->daddr = x->sel.daddr.a4;
index b198087c073ec4b68f964ab1ea8fb1c116950393..124f24bc4dbce4a9e47c859b9895100975ab0d96 100644 (file)
  */
 static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 {
-       struct iphdr *iph;
-       int ihl;
+       struct iphdr *iph = ip_hdr(skb);
+       int ihl = iph->ihl * 4;
 
-       iph = skb->nh.iph;
-       skb->h.ipiph = iph;
-
-       ihl = iph->ihl * 4;
+       skb->h.raw = skb->nh.raw;
        skb->h.raw += ihl;
 
        skb_push(skb, x->props.header_len);
@@ -54,7 +51,7 @@ static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb)
                memmove(skb->h.raw, skb_network_header(skb), ihl);
                skb->nh.raw = skb->h.raw;
        }
-       skb->nh.iph->tot_len = htons(skb->len + ihl);
+       ip_hdr(skb)->tot_len = htons(skb->len + ihl);
        skb->h.raw = skb->data;
        return 0;
 }
index bec851f278e5f3fec25e93cf69f6e2c32e9ef9da..faa1b9a76e763fc9479ae94259ff9f2ad6a59e06 100644 (file)
@@ -16,7 +16,7 @@
 
 static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
 {
-       struct iphdr *outer_iph = skb->nh.iph;
+       struct iphdr *outer_iph = ip_hdr(skb);
        struct iphdr *inner_iph = skb->h.ipiph;
 
        if (INET_ECN_is_ce(outer_iph->tos))
@@ -46,12 +46,12 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
        struct iphdr *iph, *top_iph;
        int flags;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        skb->h.ipiph = iph;
 
        skb_push(skb, x->props.header_len);
        skb_reset_network_header(skb);
-       top_iph = skb->nh.iph;
+       top_iph = ip_hdr(skb);
 
        top_iph->ihl = 5;
        top_iph->version = 4;
@@ -91,7 +91,7 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
 
 static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
 {
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        const unsigned char *old_mac;
        int err = -EINVAL;
 
@@ -113,7 +113,7 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
            (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
                goto out;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
        if (iph->protocol == IPPROTO_IPIP) {
                if (x->props.flags & XFRM_STATE_DECAP_DSCP)
                        ipv4_copy_dscp(iph, skb->h.ipiph);
index 038ca160fe2c4c67e3ba17fd39f3361fd31fa795..44ef208a75cb175bfbff21cae090212a6d996b07 100644 (file)
@@ -22,14 +22,13 @@ static int xfrm4_tunnel_check_size(struct sk_buff *skb)
 {
        int mtu, ret = 0;
        struct dst_entry *dst;
-       struct iphdr *iph = skb->nh.iph;
 
        if (IPCB(skb)->flags & IPSKB_XFRM_TUNNEL_SIZE)
                goto out;
 
        IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE;
 
-       if (!(iph->frag_off & htons(IP_DF)) || skb->local_df)
+       if (!(ip_hdr(skb)->frag_off & htons(IP_DF)) || skb->local_df)
                goto out;
 
        dst = skb->dst;
index fbb1d3decf0275b4bf8b8b61af28c014b5b89992..f1c32ff59d1616c573d1d449f55dd8436cd6219c 100644 (file)
@@ -209,7 +209,7 @@ error:
 static void
 _decode_session4(struct sk_buff *skb, struct flowi *fl)
 {
-       struct iphdr *iph = skb->nh.iph;
+       struct iphdr *iph = ip_hdr(skb);
        u8 *xprth = skb_network_header(skb) + iph->ihl * 4;
 
        memset(fl, 0, sizeof(struct flowi));
index 3eef06454da943e24599d5ca7051a5c6c5ae34c4..568510304553d14c82807eb8e29b81b8f9381079 100644 (file)
@@ -12,9 +12,8 @@
 
 static int ipip_output(struct xfrm_state *x, struct sk_buff *skb)
 {
-       struct iphdr *iph;
+       struct iphdr *iph = ip_hdr(skb);
 
-       iph = skb->nh.iph;
        iph->tot_len = htons(skb->len);
        ip_send_check(iph);
 
index 7a86db6163ee02c2fc3bee1713e8252af9d1acb5..ac95d3bfdfb76fc0a8c27ea1d6bedd48e83579a2 100644 (file)
@@ -349,8 +349,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
                        struct inet_sock *inet = inet_sk(sk);
 
                        ipv6_addr_set(&sin->sin6_addr, 0, 0,
-                                     htonl(0xffff),
-                                     skb->nh.iph->saddr);
+                                     htonl(0xffff), ip_hdr(skb)->saddr);
                        if (inet->cmsg_flags)
                                ip_cmsg_recv(msg, skb);
                }
index aafbdfa8d785b5770d86f7d6f368aacec7b0154e..bb65779be7a6072e70d8ab32497d4fb08cea58a3 100644 (file)
@@ -526,7 +526,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        skb2->dst = NULL;
        skb_pull(skb2, offset);
        skb_reset_network_header(skb2);
-       eiph = skb2->nh.iph;
+       eiph = ip_hdr(skb2);
 
        /* Try to guess incoming interface */
        memset(&fl, 0, sizeof(fl));
@@ -625,10 +625,10 @@ static void ip4ip6_dscp_ecn_decapsulate(struct ip6_tnl *t,
        __u8 dsfield = ipv6_get_dsfield(ipv6h) & ~INET_ECN_MASK;
 
        if (t->parms.flags & IP6_TNL_F_RCV_DSCP_COPY)
-               ipv4_change_dsfield(skb->nh.iph, INET_ECN_MASK, dsfield);
+               ipv4_change_dsfield(ip_hdr(skb), INET_ECN_MASK, dsfield);
 
        if (INET_ECN_is_ce(dsfield))
-               IP_ECN_set_ce(skb->nh.iph);
+               IP_ECN_set_ce(ip_hdr(skb));
 }
 
 static void ip6ip6_dscp_ecn_decapsulate(struct ip6_tnl *t,
@@ -944,7 +944,7 @@ static inline int
 ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ip6_tnl *t = netdev_priv(dev);
-       struct iphdr  *iph = skb->nh.iph;
+       struct iphdr  *iph = ip_hdr(skb);
        int encap_limit = -1;
        struct flowi fl;
        __u8 dsfield;
index 62883d41b6c37b1ebf452beb65e9b86f334c49d6..e33ac3c3a9ca6cd7341152943cf06f049be70514 100644 (file)
@@ -377,7 +377,7 @@ static int ipip6_rcv(struct sk_buff *skb)
        if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
                goto out;
 
-       iph = skb->nh.iph;
+       iph = ip_hdr(skb);
 
        read_lock(&ipip6_lock);
        if ((tunnel = ipip6_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) {
@@ -565,7 +565,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
         *      Push down and install the IPIP header.
         */
 
-       iph                     =       skb->nh.iph;
+       iph                     =       ip_hdr(skb);
        iph->version            =       4;
        iph->ihl                =       sizeof(struct iphdr)>>2;
        if (mtu > IPV6_MIN_MTU)
index 87b06a80102b1b1477e625cb866999d4a31edd21..e991e606ab1f18549934294349fdfb4937baa25f 100644 (file)
@@ -178,7 +178,7 @@ try_again:
 
                if (skb->protocol == htons(ETH_P_IP))
                        ipv6_addr_set(&sin6->sin6_addr, 0, 0,
-                                     htonl(0xffff), skb->nh.iph->saddr);
+                                     htonl(0xffff), ip_hdr(skb)->saddr);
                else {
                        ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
                        if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
index bb26a658cc1cfb423bc173e26a310347bb4da97f..1093478cc007c349c0eef2dd2dbf9b2f5cc95fea 100644 (file)
@@ -46,7 +46,7 @@ static int help(struct sk_buff **pskb, unsigned int protoff,
                struct nf_conn *ct, enum ip_conntrack_info ctinfo)
 {
        struct nf_conntrack_expect *exp;
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        struct rtable *rt = (struct rtable *)(*pskb)->dst;
        struct in_device *in_dev;
        __be32 mask = 0;
index a7cc75aeb38dc30c1934d97175a069ed133675e8..de647bd54893ab4372fbbd147423c228a702ef79 100644 (file)
@@ -35,13 +35,13 @@ static unsigned int target(struct sk_buff **pskb,
                           const void *targinfo)
 {
        const struct xt_DSCP_info *dinfo = targinfo;
-       u_int8_t dscp = ipv4_get_dsfield((*pskb)->nh.iph) >> XT_DSCP_SHIFT;
+       u_int8_t dscp = ipv4_get_dsfield(ip_hdr(*pskb)) >> XT_DSCP_SHIFT;
 
        if (dscp != dinfo->dscp) {
                if (!skb_make_writable(pskb, sizeof(struct iphdr)))
                        return NF_DROP;
 
-               ipv4_change_dsfield((*pskb)->nh.iph, (__u8)(~XT_DSCP_MASK),
+               ipv4_change_dsfield(ip_hdr(*pskb), (__u8)(~XT_DSCP_MASK),
                                    dinfo->dscp << XT_DSCP_SHIFT);
 
        }
index afc0c60e19d53d329d45c59cf2bf5f694fe5e200..9e948ce276009641abf632bcd7991c006318d312 100644 (file)
@@ -145,7 +145,7 @@ xt_tcpmss_target4(struct sk_buff **pskb,
                  const struct xt_target *target,
                  const void *targinfo)
 {
-       struct iphdr *iph = (*pskb)->nh.iph;
+       struct iphdr *iph = ip_hdr(*pskb);
        __be16 newlen;
        int ret;
 
@@ -154,7 +154,7 @@ xt_tcpmss_target4(struct sk_buff **pskb,
        if (ret < 0)
                return NF_DROP;
        if (ret > 0) {
-               iph = (*pskb)->nh.iph;
+               iph = ip_hdr(*pskb);
                newlen = htons(ntohs(iph->tot_len) + ret);
                nf_csum_replace2(&iph->check, iph->tot_len, newlen);
                iph->tot_len = newlen;
index 26c7f4ad102a0f34c1024abca184ede8aab7cd51..9ec294cd2436e5593a93e9df7b1178fe04fe72d1 100644 (file)
@@ -34,7 +34,7 @@ static int match(const struct sk_buff *skb,
                 int *hotdrop)
 {
        const struct xt_dscp_info *info = matchinfo;
-       u_int8_t dscp = ipv4_get_dsfield(skb->nh.iph) >> XT_DSCP_SHIFT;
+       u_int8_t dscp = ipv4_get_dsfield(ip_hdr(skb)) >> XT_DSCP_SHIFT;
 
        return (dscp == info->dscp) ^ !!info->invert;
 }
index 9f37d593ca38a2badf2677cfa98753e6d84c2ea9..47af19ab03cf5c83093ed6208a84eabf0097f74d 100644 (file)
@@ -380,14 +380,14 @@ hashlimit_init_dst(struct xt_hashlimit_htable *hinfo, struct dsthash_dst *dst,
        switch (hinfo->family) {
        case AF_INET:
                if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_DIP)
-                       dst->addr.ip.dst = skb->nh.iph->daddr;
+                       dst->addr.ip.dst = ip_hdr(skb)->daddr;
                if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_SIP)
-                       dst->addr.ip.src = skb->nh.iph->saddr;
+                       dst->addr.ip.src = ip_hdr(skb)->saddr;
 
                if (!(hinfo->cfg.mode &
                      (XT_HASHLIMIT_HASH_DPT | XT_HASHLIMIT_HASH_SPT)))
                        return 0;
-               nexthdr = skb->nh.iph->protocol;
+               nexthdr = ip_hdr(skb)->protocol;
                break;
 #if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
        case AF_INET6:
index 32fb998d9bac6e49f2d237afc3d10291f38c2224..65fdb2166996984ff5a0d26c4afb8a4740290977 100644 (file)
@@ -31,7 +31,7 @@ match(const struct sk_buff *skb,
       int *hotdrop)
 {
        const struct xt_length_info *info = matchinfo;
-       u_int16_t pktlen = ntohs(skb->nh.iph->tot_len);
+       u_int16_t pktlen = ntohs(ip_hdr(skb)->tot_len);
 
        return (pktlen >= info->min && pktlen <= info->max) ^ info->invert;
 }
index 16e7b080428760c69559135a49bd3cfe76cbad81..e1409fc5c2881f81e0affb61eef149ed6c724f12 100644 (file)
@@ -34,7 +34,7 @@ static int match(const struct sk_buff *skb,
        const struct xt_pkttype_info *info = matchinfo;
 
        if (skb->pkt_type == PACKET_LOOPBACK)
-               type = (MULTICAST(skb->nh.iph->daddr)
+               type = (MULTICAST(ip_hdr(skb)->daddr)
                        ? PACKET_MULTICAST
                        : PACKET_BROADCAST);
        else
index a7c929a9fdca89070c1fa70d4dc9a0b4a4275664..e601fa87bb77a99a0766c54e8514d819d45ab393 100644 (file)
@@ -267,7 +267,7 @@ int rxrpc_connection_lookup(struct rxrpc_peer *peer,
                /* fill in the specifics */
                candidate->addr.sin_family      = AF_INET;
                candidate->addr.sin_port        = x_port;
-               candidate->addr.sin_addr.s_addr = pkt->nh.iph->saddr;
+               candidate->addr.sin_addr.s_addr = ip_hdr(pkt)->saddr;
                candidate->in_epoch             = x_epoch;
                candidate->out_epoch            = x_epoch;
                candidate->in_clientflag        = RXRPC_CLIENT_INITIATED;
index 8e57be2df93625867d470eb5185fe22114ec513d..cac078b7406895b4953590b2f05fa5feed584840 100644 (file)
@@ -478,7 +478,7 @@ void rxrpc_trans_receive_packet(struct rxrpc_transport *trans)
                        return;
                }
 
-               addr = pkt->nh.iph->saddr;
+               addr = ip_hdr(pkt)->saddr;
                port = pkt->h.uh->source;
 
                _net("Rx Received UDP packet from %08x:%04hu",
@@ -626,7 +626,7 @@ int rxrpc_trans_immediate_abort(struct rxrpc_transport *trans,
        memset(&sin,0,sizeof(sin));
        sin.sin_family          = AF_INET;
        sin.sin_port            = msg->pkt->h.uh->source;
-       sin.sin_addr.s_addr     = msg->pkt->nh.iph->saddr;
+       sin.sin_addr.s_addr     = ip_hdr(msg->pkt)->saddr;
 
        msghdr.msg_name         = &sin;
        msghdr.msg_namelen      = sizeof(sin);
index b6ac0e287872485060f9098d82fe028e59ad1cb6..cb8cf5bfa053d75255c0fec4495d768332e6a13f 100644 (file)
@@ -145,7 +145,7 @@ static int rsvp_classify(struct sk_buff *skb, struct tcf_proto *tp,
 #if RSVP_DST_LEN == 4
        struct ipv6hdr *nhptr = skb->nh.ipv6h;
 #else
-       struct iphdr *nhptr = skb->nh.iph;
+       struct iphdr *nhptr = ip_hdr(skb);
 #endif
 
 restart:
index afb3bbd571f27d981909ac3264eff661a235e28c..baca8743c12ba78a70dc2f08b9acc8cfd33babea 100644 (file)
@@ -503,7 +503,7 @@ static void sch_atm_dequeue(unsigned long data)
                        }
                        D2PRINTK("atm_tc_dequeue: sending on class %p\n",flow);
                        /* remove any LL header somebody else has attached */
-                       skb_pull(skb,(char *) skb->nh.iph-(char *) skb->data);
+                       skb_pull(skb, skb_network_offset(skb));
                        if (skb_headroom(skb) < flow->hdr_len) {
                                struct sk_buff *new;
 
@@ -513,7 +513,7 @@ static void sch_atm_dequeue(unsigned long data)
                                skb = new;
                        }
                        D2PRINTK("sch_atm_dequeue: ip %p, data %p\n",
-                           skb->nh.iph,skb->data);
+                                skb_network_header(skb), skb->data);
                        ATM_SKB(skb)->vcc = flow->vcc;
                        memcpy(skb_push(skb,flow->hdr_len),flow->hdr,
                            flow->hdr_len);
index 96324cf4e6a9ac9a1046cfd294d66ab0ec0a82cd..45b5734dd72a7da578db5e2cdf61935bb9b0e1c7 100644 (file)
@@ -216,7 +216,7 @@ static int dsmark_enqueue(struct sk_buff *skb,struct Qdisc *sch)
                /* FIXME: Safe with non-linear skbs? --RR */
                switch (skb->protocol) {
                        case __constant_htons(ETH_P_IP):
-                               skb->tc_index = ipv4_get_dsfield(skb->nh.iph)
+                               skb->tc_index = ipv4_get_dsfield(ip_hdr(skb))
                                        & ~INET_ECN_MASK;
                                break;
                        case __constant_htons(ETH_P_IPV6):
@@ -292,7 +292,7 @@ static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
 
        switch (skb->protocol) {
                case __constant_htons(ETH_P_IP):
-                       ipv4_change_dsfield(skb->nh.iph, p->mask[index],
+                       ipv4_change_dsfield(ip_hdr(skb), p->mask[index],
                                            p->value[index]);
                        break;
                case __constant_htons(ETH_P_IPV6):
index 66f32051a99b4b182adf0db17fdb0c29ae67c3c8..02081bc9e0d14b85b1f1ba2627685730bfc70e50 100644 (file)
@@ -137,7 +137,7 @@ static unsigned sfq_hash(struct sfq_sched_data *q, struct sk_buff *skb)
        switch (skb->protocol) {
        case __constant_htons(ETH_P_IP):
        {
-               struct iphdr *iph = skb->nh.iph;
+               const struct iphdr *iph = ip_hdr(skb);
                h = iph->daddr;
                h2 = iph->saddr^iph->protocol;
                if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
index 2b0863aba3fb3f3b5c4050196bccbf79908c232b..595fe32b3d41ef238664b757449aeddd5b7fbb7c 100644 (file)
@@ -154,7 +154,7 @@ int sctp_rcv(struct sk_buff *skb)
        if (skb->len < sizeof(struct sctp_chunkhdr))
                goto discard_it;
 
-       family = ipver2af(skb->nh.iph->version);
+       family = ipver2af(ip_hdr(skb)->version);
        af = sctp_get_af_specific(family);
        if (unlikely(!af))
                goto discard_it;
index 5f9b145b0b90ca21c0d9dafca93697e5aacfbc0b..742f9ff42fbfddf32d3d3bbd6ba5a12bee2c94db 100644 (file)
@@ -770,9 +770,9 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname,
 
                /* Map ipv4 address into v4-mapped-on-v6 address. */
                if (sctp_sk(skb->sk)->v4mapped &&
-                   skb->nh.iph->version == 4) {
+                   ip_hdr(skb)->version == 4) {
                        sctp_v4_map_v6((union sctp_addr *)sin6);
-                       sin6->sin6_addr.s6_addr32[3] = skb->nh.iph->saddr;
+                       sin6->sin6_addr.s6_addr32[3] = ip_hdr(skb)->saddr;
                        return;
                }
 
index e17a823ca90fcecc1d6e5da68d7ad6b9ea70eeee..08f92ba4ebd7e5758bed6f18672127cdd4f5c08e 100644 (file)
@@ -238,10 +238,10 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
        sh = (struct sctphdr *) skb->h.raw;
        if (is_saddr) {
                *port  = sh->source;
-               from = &skb->nh.iph->saddr;
+               from = &ip_hdr(skb)->saddr;
        } else {
                *port = sh->dest;
-               from = &skb->nh.iph->daddr;
+               from = &ip_hdr(skb)->daddr;
        }
        memcpy(&addr->v4.sin_addr.s_addr, from, sizeof(struct in_addr));
 }
@@ -530,7 +530,7 @@ static int sctp_v4_skb_iif(const struct sk_buff *skb)
 /* Was this packet marked by Explicit Congestion Notification? */
 static int sctp_v4_is_ce(const struct sk_buff *skb)
 {
-       return INET_ECN_is_ce(skb->nh.iph->tos);
+       return INET_ECN_is_ce(ip_hdr(skb)->tos);
 }
 
 /* Create and initialize a new sk for the socket returned by accept(). */
@@ -739,7 +739,7 @@ static void sctp_inet_skb_msgname(struct sk_buff *skb, char *msgname, int *len)
                sin = (struct sockaddr_in *)msgname;
                sh = (struct sctphdr *)skb->h.raw;
                sin->sin_port = sh->source;
-               sin->sin_addr.s_addr = skb->nh.iph->saddr;
+               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
        }
 }
 
index f7fb29d5a0c728ea83cad16b54bfe6671b06d81d..60c5b59d4c65a891f8a8d5e93ceee4b1ca84163e 100644 (file)
@@ -86,7 +86,7 @@ int sctp_chunk_iif(const struct sctp_chunk *chunk)
        struct sctp_af *af;
        int iif = 0;
 
-       af = sctp_get_af_specific(ipver2af(chunk->skb->nh.iph->version));
+       af = sctp_get_af_specific(ipver2af(ip_hdr(chunk->skb)->version));
        if (af)
                iif = af->skb_iif(chunk->skb);
 
@@ -1233,7 +1233,7 @@ struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep,
        asoc->temp = 1;
        skb = chunk->skb;
        /* Create an entry for the source address of the packet.  */
-       af = sctp_get_af_specific(ipver2af(skb->nh.iph->version));
+       af = sctp_get_af_specific(ipver2af(ip_hdr(skb)->version));
        if (unlikely(!af))
                goto fail;
        af->from_skb(&asoc->c.peer_addr, skb, 1);
index e9097cf614ba6b18c984bab06b0e18bb7268a71f..bf502c499c8153578a314f23495d871f906bfe86 100644 (file)
@@ -5286,7 +5286,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,
                chunk->ecn_ce_done = 1;
 
                af = sctp_get_af_specific(
-                       ipver2af(chunk->skb->nh.iph->version));
+                       ipver2af(ip_hdr(chunk->skb)->version));
 
                if (af && af->is_ce(chunk->skb) && asoc->peer.ecn_capable) {
                        /* Do real work as sideffect. */