|
@@ -1591,6 +1591,34 @@ int tcp_filter(struct sock *sk, struct sk_buff *skb)
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(tcp_filter);
|
|
EXPORT_SYMBOL(tcp_filter);
|
|
|
|
|
|
|
|
+static void tcp_v4_restore_cb(struct sk_buff *skb)
|
|
|
|
+{
|
|
|
|
+ memmove(IPCB(skb), &TCP_SKB_CB(skb)->header.h4,
|
|
|
|
+ sizeof(struct inet_skb_parm));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph,
|
|
|
|
+ const struct tcphdr *th)
|
|
|
|
+{
|
|
|
|
+ /* This is tricky : We move IPCB at its correct location into TCP_SKB_CB()
|
|
|
|
+ * barrier() makes sure compiler wont play fool^Waliasing games.
|
|
|
|
+ */
|
|
|
|
+ memmove(&TCP_SKB_CB(skb)->header.h4, IPCB(skb),
|
|
|
|
+ sizeof(struct inet_skb_parm));
|
|
|
|
+ barrier();
|
|
|
|
+
|
|
|
|
+ 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)->tcp_flags = tcp_flag_byte(th);
|
|
|
|
+ TCP_SKB_CB(skb)->tcp_tw_isn = 0;
|
|
|
|
+ TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph);
|
|
|
|
+ TCP_SKB_CB(skb)->sacked = 0;
|
|
|
|
+ TCP_SKB_CB(skb)->has_rxtstamp =
|
|
|
|
+ skb->tstamp || skb_hwtstamps(skb)->hwtstamp;
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* From tcp_input.c
|
|
* From tcp_input.c
|
|
*/
|
|
*/
|
|
@@ -1631,24 +1659,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
|
|
|
|
|
|
th = (const struct tcphdr *)skb->data;
|
|
th = (const struct tcphdr *)skb->data;
|
|
iph = ip_hdr(skb);
|
|
iph = ip_hdr(skb);
|
|
- /* This is tricky : We move IPCB at its correct location into TCP_SKB_CB()
|
|
|
|
- * barrier() makes sure compiler wont play fool^Waliasing games.
|
|
|
|
- */
|
|
|
|
- memmove(&TCP_SKB_CB(skb)->header.h4, IPCB(skb),
|
|
|
|
- sizeof(struct inet_skb_parm));
|
|
|
|
- barrier();
|
|
|
|
-
|
|
|
|
- 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)->tcp_flags = tcp_flag_byte(th);
|
|
|
|
- TCP_SKB_CB(skb)->tcp_tw_isn = 0;
|
|
|
|
- TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph);
|
|
|
|
- TCP_SKB_CB(skb)->sacked = 0;
|
|
|
|
- TCP_SKB_CB(skb)->has_rxtstamp =
|
|
|
|
- skb->tstamp || skb_hwtstamps(skb)->hwtstamp;
|
|
|
|
-
|
|
|
|
lookup:
|
|
lookup:
|
|
sk = __inet_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th), th->source,
|
|
sk = __inet_lookup_skb(&tcp_hashinfo, skb, __tcp_hdrlen(th), th->source,
|
|
th->dest, sdif, &refcounted);
|
|
th->dest, sdif, &refcounted);
|
|
@@ -1679,14 +1689,19 @@ process:
|
|
sock_hold(sk);
|
|
sock_hold(sk);
|
|
refcounted = true;
|
|
refcounted = true;
|
|
nsk = NULL;
|
|
nsk = NULL;
|
|
- if (!tcp_filter(sk, skb))
|
|
|
|
|
|
+ if (!tcp_filter(sk, skb)) {
|
|
|
|
+ th = (const struct tcphdr *)skb->data;
|
|
|
|
+ iph = ip_hdr(skb);
|
|
|
|
+ tcp_v4_fill_cb(skb, iph, th);
|
|
nsk = tcp_check_req(sk, skb, req, false);
|
|
nsk = tcp_check_req(sk, skb, req, false);
|
|
|
|
+ }
|
|
if (!nsk) {
|
|
if (!nsk) {
|
|
reqsk_put(req);
|
|
reqsk_put(req);
|
|
goto discard_and_relse;
|
|
goto discard_and_relse;
|
|
}
|
|
}
|
|
if (nsk == sk) {
|
|
if (nsk == sk) {
|
|
reqsk_put(req);
|
|
reqsk_put(req);
|
|
|
|
+ tcp_v4_restore_cb(skb);
|
|
} else if (tcp_child_process(sk, nsk, skb)) {
|
|
} else if (tcp_child_process(sk, nsk, skb)) {
|
|
tcp_v4_send_reset(nsk, skb);
|
|
tcp_v4_send_reset(nsk, skb);
|
|
goto discard_and_relse;
|
|
goto discard_and_relse;
|
|
@@ -1712,6 +1727,7 @@ process:
|
|
goto discard_and_relse;
|
|
goto discard_and_relse;
|
|
th = (const struct tcphdr *)skb->data;
|
|
th = (const struct tcphdr *)skb->data;
|
|
iph = ip_hdr(skb);
|
|
iph = ip_hdr(skb);
|
|
|
|
+ tcp_v4_fill_cb(skb, iph, th);
|
|
|
|
|
|
skb->dev = NULL;
|
|
skb->dev = NULL;
|
|
|
|
|
|
@@ -1742,6 +1758,8 @@ no_tcp_socket:
|
|
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
|
|
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
|
|
goto discard_it;
|
|
goto discard_it;
|
|
|
|
|
|
|
|
+ tcp_v4_fill_cb(skb, iph, th);
|
|
|
|
+
|
|
if (tcp_checksum_complete(skb)) {
|
|
if (tcp_checksum_complete(skb)) {
|
|
csum_error:
|
|
csum_error:
|
|
__TCP_INC_STATS(net, TCP_MIB_CSUMERRORS);
|
|
__TCP_INC_STATS(net, TCP_MIB_CSUMERRORS);
|
|
@@ -1768,6 +1786,8 @@ do_time_wait:
|
|
goto discard_it;
|
|
goto discard_it;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ tcp_v4_fill_cb(skb, iph, th);
|
|
|
|
+
|
|
if (tcp_checksum_complete(skb)) {
|
|
if (tcp_checksum_complete(skb)) {
|
|
inet_twsk_put(inet_twsk(sk));
|
|
inet_twsk_put(inet_twsk(sk));
|
|
goto csum_error;
|
|
goto csum_error;
|
|
@@ -1784,6 +1804,7 @@ do_time_wait:
|
|
if (sk2) {
|
|
if (sk2) {
|
|
inet_twsk_deschedule_put(inet_twsk(sk));
|
|
inet_twsk_deschedule_put(inet_twsk(sk));
|
|
sk = sk2;
|
|
sk = sk2;
|
|
|
|
+ tcp_v4_restore_cb(skb);
|
|
refcounted = false;
|
|
refcounted = false;
|
|
goto process;
|
|
goto process;
|
|
}
|
|
}
|