aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp.c12
-rw-r--r--net/ipv4/tcp_ipv4.c36
-rw-r--r--net/ipv4/tcp_offload.c8
3 files changed, 36 insertions, 20 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 744af67a5989..181b70ebd964 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -426,13 +426,15 @@ void tcp_init_sock(struct sock *sk)
426} 426}
427EXPORT_SYMBOL(tcp_init_sock); 427EXPORT_SYMBOL(tcp_init_sock);
428 428
429void tcp_tx_timestamp(struct sock *sk, struct sk_buff *skb) 429static void tcp_tx_timestamp(struct sock *sk, struct sk_buff *skb)
430{ 430{
431 struct skb_shared_info *shinfo = skb_shinfo(skb); 431 if (sk->sk_tsflags) {
432 struct skb_shared_info *shinfo = skb_shinfo(skb);
432 433
433 sock_tx_timestamp(sk, &shinfo->tx_flags); 434 sock_tx_timestamp(sk, &shinfo->tx_flags);
434 if (shinfo->tx_flags & SKBTX_ANY_SW_TSTAMP) 435 if (shinfo->tx_flags & SKBTX_ANY_TSTAMP)
435 shinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1; 436 shinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1;
437 }
436} 438}
437 439
438/* 440/*
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 992a1f926009..dceff5fe8e66 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1167,7 +1167,8 @@ clear_hash_noput:
1167} 1167}
1168EXPORT_SYMBOL(tcp_v4_md5_hash_skb); 1168EXPORT_SYMBOL(tcp_v4_md5_hash_skb);
1169 1169
1170static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) 1170static bool __tcp_v4_inbound_md5_hash(struct sock *sk,
1171 const struct sk_buff *skb)
1171{ 1172{
1172 /* 1173 /*
1173 * This gets called for each TCP segment that arrives 1174 * This gets called for each TCP segment that arrives
@@ -1220,6 +1221,17 @@ static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1220 return false; 1221 return false;
1221} 1222}
1222 1223
1224static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1225{
1226 bool ret;
1227
1228 rcu_read_lock();
1229 ret = __tcp_v4_inbound_md5_hash(sk, skb);
1230 rcu_read_unlock();
1231
1232 return ret;
1233}
1234
1223#endif 1235#endif
1224 1236
1225static void tcp_v4_init_req(struct request_sock *req, struct sock *sk, 1237static void tcp_v4_init_req(struct request_sock *req, struct sock *sk,
@@ -1432,16 +1444,6 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
1432int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) 1444int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
1433{ 1445{
1434 struct sock *rsk; 1446 struct sock *rsk;
1435#ifdef CONFIG_TCP_MD5SIG
1436 /*
1437 * We really want to reject the packet as early as possible
1438 * if:
1439 * o We're expecting an MD5'd packet and this is no MD5 tcp option
1440 * o There is an MD5 option and we're not expecting one
1441 */
1442 if (tcp_v4_inbound_md5_hash(sk, skb))
1443 goto discard;
1444#endif
1445 1447
1446 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ 1448 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
1447 struct dst_entry *dst = sk->sk_rx_dst; 1449 struct dst_entry *dst = sk->sk_rx_dst;
@@ -1644,6 +1646,18 @@ process:
1644 1646
1645 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) 1647 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
1646 goto discard_and_relse; 1648 goto discard_and_relse;
1649
1650#ifdef CONFIG_TCP_MD5SIG
1651 /*
1652 * We really want to reject the packet as early as possible
1653 * if:
1654 * o We're expecting an MD5'd packet and this is no MD5 tcp option
1655 * o There is an MD5 option and we're not expecting one
1656 */
1657 if (tcp_v4_inbound_md5_hash(sk, skb))
1658 goto discard_and_relse;
1659#endif
1660
1647 nf_reset(skb); 1661 nf_reset(skb);
1648 1662
1649 if (sk_filter(sk, skb)) 1663 if (sk_filter(sk, skb))
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index f597119fc4e7..bc1b83cb8309 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -14,12 +14,12 @@
14#include <net/tcp.h> 14#include <net/tcp.h>
15#include <net/protocol.h> 15#include <net/protocol.h>
16 16
17void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq, unsigned int seq, 17static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq,
18 unsigned int mss) 18 unsigned int seq, unsigned int mss)
19{ 19{
20 while (skb) { 20 while (skb) {
21 if (ts_seq < (__u64) seq + mss) { 21 if (before(ts_seq, seq + mss)) {
22 skb_shinfo(skb)->tx_flags = SKBTX_SW_TSTAMP; 22 skb_shinfo(skb)->tx_flags |= SKBTX_SW_TSTAMP;
23 skb_shinfo(skb)->tskey = ts_seq; 23 skb_shinfo(skb)->tskey = ts_seq;
24 return; 24 return;
25 } 25 }