Skip to content

Commit

Permalink
[SK_BUFF]: Introduce tcp_hdr(), remove skb->h.th
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
acmel authored and David S. Miller committed Apr 26, 2007
1 parent ab6a5bb commit aa8223c
Show file tree
Hide file tree
Showing 23 changed files with 134 additions and 122 deletions.
7 changes: 4 additions & 3 deletions drivers/net/atl1/atl1_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1298,9 +1298,10 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,

iph->tot_len = 0;
iph->check = 0;
skb->h.th->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr, 0,
IPPROTO_TCP, 0);
tcp_hdr(skb)->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;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/bnx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4524,17 +4524,17 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
vlan_tag_flags |= TX_BD_FLAGS_SW_LSO;

tcp_opt_len = 0;
if (skb->h.th->doff > 5)
if (tcp_hdr(skb)->doff > 5)
tcp_opt_len = tcp_optlen(skb);

ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr);

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);

tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr, 0,
IPPROTO_TCP, 0);
if (tcp_opt_len || (iph->ihl > 5)) {
vlan_tag_flags |= ((iph->ihl - 5) +
(tcp_opt_len >> 2)) << 8;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/chelsio/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
hdr->opcode = CPL_TX_PKT_LSO;
hdr->ip_csum_dis = hdr->l4_csum_dis = 0;
hdr->ip_hdr_words = ip_hdr(skb)->ihl;
hdr->tcp_hdr_words = skb->h.th->doff;
hdr->tcp_hdr_words = tcp_hdr(skb)->doff;
hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
skb_shinfo(skb)->gso_size));
hdr->len = htonl(skb->len - sizeof(*hdr));
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/cxgb3/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
CPL_ETH_II : CPL_ETH_II_VLAN;
tso_info |= V_LSO_ETH_TYPE(eth_type) |
V_LSO_IPHDR_WORDS(ip_hdr(skb)->ihl) |
V_LSO_TCPHDR_WORDS(skb->h.th->doff);
V_LSO_TCPHDR_WORDS(tcp_hdr(skb)->doff);
hdr->lso_info = htonl(tso_info);
flits = 3;
} else {
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2893,14 +2893,15 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
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);
tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr, 0,
IPPROTO_TCP,
0);
cmd_length = E1000_TXD_CMD_IP;
ipcse = skb_transport_offset(skb) - 1;
} else if (skb->protocol == htons(ETH_P_IPV6)) {
ipv6_hdr(skb)->payload_len = 0;
skb->h.th->check =
tcp_hdr(skb)->check =
~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
&ipv6_hdr(skb)->daddr,
0, IPPROTO_TCP, 0);
Expand All @@ -2909,7 +2910,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
ipcss = skb_network_offset(skb);
ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
tucss = skb_transport_offset(skb);
tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
tucse = 0;

cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ioc3-eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (proto == IPPROTO_TCP) {
csoff += offsetof(struct tcphdr, check);
skb->h.th->check = csum;
tcp_hdr(skb)->check = csum;
}

w0 = ETXD_DOCHECKSUM | (csoff << ETXD_CHKOFF_SHIFT);
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/ixgb/ixgb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1195,13 +1195,14 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
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);
tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr, 0,
IPPROTO_TCP, 0);
ipcss = skb_network_offset(skb);
ipcso = (void *)&(iph->check) - (void *)skb->data;
ipcse = skb_transport_offset(skb) - 1;
tucss = skb_transport_offset(skb);
tucso = (void *)&(skb->h.th->check) - (void *)skb->data;
tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
tucse = 0;

i = adapter->tx_ring.next_to_use;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/mv643xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
desc->l4i_chk = udp_hdr(skb)->check;
break;
case IPPROTO_TCP:
desc->l4i_chk = skb->h.th->check;
desc->l4i_chk = tcp_hdr(skb)->check;
break;
default:
BUG();
Expand Down
15 changes: 7 additions & 8 deletions drivers/net/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
base_flags |= (TXD_FLAG_CPU_PRE_DMA |
TXD_FLAG_CPU_POST_DMA);

skb->h.th->check = 0;
tcp_hdr(skb)->check = 0;

}
else if (skb->ip_summed == CHECKSUM_PARTIAL)
Expand Down Expand Up @@ -4080,14 +4080,13 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
iph->check = 0;
iph->tot_len = htons(mss + hdr_len);
if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
skb->h.th->check = 0;
tcp_hdr(skb)->check = 0;
base_flags &= ~TXD_FLAG_TCPUDP_CSUM;
}
else {
skb->h.th->check = ~csum_tcpudp_magic(iph->saddr,
iph->daddr, 0,
IPPROTO_TCP, 0);
}
} else
tcp_hdr(skb)->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)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/net/qeth_eddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
eddp->skb_offset += VLAN_HLEN;
#endif /* CONFIG_QETH_VLAN */
}
tcph = eddp->skb->h.th;
tcph = tcp_hdr(eddp->skb);
while (eddp->skb_offset < eddp->skb->len) {
data_len = min((int)skb_shinfo(eddp->skb)->gso_size,
(int)(eddp->skb->len - eddp->skb_offset));
Expand Down
4 changes: 2 additions & 2 deletions drivers/s390/net/qeth_tso.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ qeth_tso_fill_header(struct qeth_card *card, struct sk_buff *skb)

hdr = (struct qeth_hdr_tso *) skb->data;
iph = ip_hdr(skb);
tcph = skb->h.th;
tcph = tcp_hdr(skb);
/*fix header to TSO values ...*/
hdr->hdr.hdr.l3.id = QETH_HEADER_TYPE_TSO;
/*set values which are fix for the first approach ...*/
Expand All @@ -65,7 +65,7 @@ qeth_tso_set_tcpip_header(struct qeth_card *card, struct sk_buff *skb)
{
struct iphdr *iph = ip_hdr(skb);
struct ipv6hdr *ip6h = ipv6_hdr(skb);
struct tcphdr *tcph = skb->h.th;
struct tcphdr *tcph = tcp_hdr(skb);

tcph->check = 0;
if (skb->protocol == ETH_P_IPV6) {
Expand Down
1 change: 0 additions & 1 deletion include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ struct sk_buff {
/* 4 byte hole on 64 bit*/

union {
struct tcphdr *th;
struct iphdr *ipiph;
struct ipv6hdr *ipv6h;
unsigned char *raw;
Expand Down
9 changes: 7 additions & 2 deletions include/linux/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,19 @@ struct tcp_md5sig {
#include <net/inet_connection_sock.h>
#include <net/inet_timewait_sock.h>

static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
{
return (struct tcphdr *)skb->h.raw;
}

static inline unsigned int tcp_hdrlen(const struct sk_buff *skb)
{
return skb->h.th->doff * 4;
return tcp_hdr(skb)->doff * 4;
}

static inline unsigned int tcp_optlen(const struct sk_buff *skb)
{
return (skb->h.th->doff - 5) * 4;
return (tcp_hdr(skb)->doff - 5) * 4;
}

/* This defines a selective acknowledgement block. */
Expand Down
2 changes: 1 addition & 1 deletion include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ static inline void tcp_openreq_init(struct request_sock *req,
ireq->wscale_ok = rx_opt->wscale_ok;
ireq->acked = 0;
ireq->ecn_ok = 0;
ireq->rmt_port = skb->h.th->source;
ireq->rmt_port = tcp_hdr(skb)->source;
}

extern void tcp_enter_memory_pressure(void);
Expand Down
6 changes: 3 additions & 3 deletions include/net/tcp_ecn.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ static inline void TCP_ECN_send(struct sock *sk, struct tcp_sock *tp,
INET_ECN_xmit(sk);
if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
skb->h.th->cwr = 1;
tcp_hdr(skb)->cwr = 1;
skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
}
} else {
/* ACK or retransmitted segment: clear ECT|CE */
INET_ECN_dontxmit(sk);
}
if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
skb->h.th->ece = 1;
tcp_hdr(skb)->ece = 1;
}
}

/* Input functions */

static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb)
{
if (skb->h.th->cwr)
if (tcp_hdr(skb)->cwr)
tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
}

Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/ip_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,8 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
.tos = RT_TOS(ip_hdr(skb)->tos) } },
/* Not quite clean, but right. */
.uli_u = { .ports =
{ .sport = skb->h.th->dest,
.dport = skb->h.th->source } },
{ .sport = tcp_hdr(skb)->dest,
.dport = tcp_hdr(skb)->source } },
.proto = sk->sk_protocol };
security_skb_classify_flow(skb, &fl);
if (ip_route_output_key(&rt, &fl))
Expand Down
36 changes: 18 additions & 18 deletions net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ static __u16 const msstab[] = {
__u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
{
struct tcp_sock *tp = tcp_sk(sk);
const struct iphdr *iph = ip_hdr(skb);
const struct tcphdr *th = tcp_hdr(skb);
int mssind;
const __u16 mss = *mssp;


tp->last_synq_overflow = jiffies;

/* XXX sort msstab[] by probability? Binary search? */
Expand All @@ -138,9 +139,8 @@ __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(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
skb->h.th->source, skb->h.th->dest,
ntohl(skb->h.th->seq),
return secure_tcp_syn_cookie(iph->saddr, iph->daddr,
th->source, th->dest, ntohl(th->seq),
jiffies / (HZ * 60), mssind);
}

Expand All @@ -157,14 +157,13 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
*/
static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
{
__u32 seq;
__u32 mssind;

seq = ntohl(skb->h.th->seq)-1;
mssind = check_tcp_syn_cookie(cookie,
ip_hdr(skb)->saddr, ip_hdr(skb)->daddr,
skb->h.th->source, skb->h.th->dest,
seq, jiffies / (HZ * 60), COUNTER_TRIES);
const struct iphdr *iph = ip_hdr(skb);
const struct tcphdr *th = tcp_hdr(skb);
__u32 seq = ntohl(th->seq) - 1;
__u32 mssind = check_tcp_syn_cookie(cookie, iph->saddr, iph->daddr,
th->source, th->dest, seq,
jiffies / (HZ * 60),
COUNTER_TRIES);

return mssind < NUM_MSS ? msstab[mssind] + 1 : 0;
}
Expand All @@ -191,14 +190,15 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
struct inet_request_sock *ireq;
struct tcp_request_sock *treq;
struct tcp_sock *tp = tcp_sk(sk);
__u32 cookie = ntohl(skb->h.th->ack_seq) - 1;
const struct tcphdr *th = tcp_hdr(skb);
__u32 cookie = ntohl(th->ack_seq) - 1;
struct sock *ret = sk;
struct request_sock *req;
int mss;
struct rtable *rt;
__u8 rcv_wscale;

if (!sysctl_tcp_syncookies || !skb->h.th->ack)
if (!sysctl_tcp_syncookies || !th->ack)
goto out;

if (time_after(jiffies, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
Expand All @@ -220,10 +220,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
}
ireq = inet_rsk(req);
treq = tcp_rsk(req);
treq->rcv_isn = ntohl(skb->h.th->seq) - 1;
treq->rcv_isn = ntohl(th->seq) - 1;
treq->snt_isn = cookie;
req->mss = mss;
ireq->rmt_port = skb->h.th->source;
ireq->rmt_port = th->source;
ireq->loc_addr = ip_hdr(skb)->daddr;
ireq->rmt_addr = ip_hdr(skb)->saddr;
ireq->opt = NULL;
Expand Down Expand Up @@ -261,8 +261,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
.tos = RT_CONN_FLAGS(sk) } },
.proto = IPPROTO_TCP,
.uli_u = { .ports =
{ .sport = skb->h.th->dest,
.dport = skb->h.th->source } } };
{ .sport = th->dest,
.dport = th->source } } };
security_req_classify_flow(req, &fl);
if (ip_route_output_key(&rt, &fl)) {
reqsk_free(req);
Expand Down
Loading

0 comments on commit aa8223c

Please sign in to comment.