diff options
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
| -rw-r--r-- | net/ipv4/tcp_ipv4.c | 172 |
1 files changed, 79 insertions, 93 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index dad98e4a5043..2d41d5d6ad19 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | * ACK bit. | 36 | * ACK bit. |
| 37 | * Andi Kleen : Implemented fast path mtu discovery. | 37 | * Andi Kleen : Implemented fast path mtu discovery. |
| 38 | * Fixed many serious bugs in the | 38 | * Fixed many serious bugs in the |
| 39 | * open_request handling and moved | 39 | * request_sock handling and moved |
| 40 | * most of it into the af independent code. | 40 | * most of it into the af independent code. |
| 41 | * Added tail drop and some other bugfixes. | 41 | * Added tail drop and some other bugfixes. |
| 42 | * Added new listen sematics. | 42 | * Added new listen sematics. |
| @@ -869,21 +869,23 @@ static __inline__ u32 tcp_v4_synq_hash(u32 raddr, u16 rport, u32 rnd) | |||
| 869 | return (jhash_2words(raddr, (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1)); | 869 | return (jhash_2words(raddr, (u32) rport, rnd) & (TCP_SYNQ_HSIZE - 1)); |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | static struct open_request *tcp_v4_search_req(struct tcp_sock *tp, | 872 | static struct request_sock *tcp_v4_search_req(struct tcp_sock *tp, |
| 873 | struct open_request ***prevp, | 873 | struct request_sock ***prevp, |
| 874 | __u16 rport, | 874 | __u16 rport, |
| 875 | __u32 raddr, __u32 laddr) | 875 | __u32 raddr, __u32 laddr) |
| 876 | { | 876 | { |
| 877 | struct tcp_listen_opt *lopt = tp->listen_opt; | 877 | struct listen_sock *lopt = tp->accept_queue.listen_opt; |
| 878 | struct open_request *req, **prev; | 878 | struct request_sock *req, **prev; |
| 879 | 879 | ||
| 880 | for (prev = &lopt->syn_table[tcp_v4_synq_hash(raddr, rport, lopt->hash_rnd)]; | 880 | for (prev = &lopt->syn_table[tcp_v4_synq_hash(raddr, rport, lopt->hash_rnd)]; |
| 881 | (req = *prev) != NULL; | 881 | (req = *prev) != NULL; |
| 882 | prev = &req->dl_next) { | 882 | prev = &req->dl_next) { |
| 883 | if (req->rmt_port == rport && | 883 | const struct inet_request_sock *ireq = inet_rsk(req); |
| 884 | req->af.v4_req.rmt_addr == raddr && | 884 | |
| 885 | req->af.v4_req.loc_addr == laddr && | 885 | if (ireq->rmt_port == rport && |
| 886 | TCP_INET_FAMILY(req->class->family)) { | 886 | ireq->rmt_addr == raddr && |
| 887 | ireq->loc_addr == laddr && | ||
| 888 | TCP_INET_FAMILY(req->rsk_ops->family)) { | ||
| 887 | BUG_TRAP(!req->sk); | 889 | BUG_TRAP(!req->sk); |
| 888 | *prevp = prev; | 890 | *prevp = prev; |
| 889 | break; | 891 | break; |
| @@ -893,21 +895,13 @@ static struct open_request *tcp_v4_search_req(struct tcp_sock *tp, | |||
| 893 | return req; | 895 | return req; |
| 894 | } | 896 | } |
| 895 | 897 | ||
| 896 | static void tcp_v4_synq_add(struct sock *sk, struct open_request *req) | 898 | static void tcp_v4_synq_add(struct sock *sk, struct request_sock *req) |
| 897 | { | 899 | { |
| 898 | struct tcp_sock *tp = tcp_sk(sk); | 900 | struct tcp_sock *tp = tcp_sk(sk); |
| 899 | struct tcp_listen_opt *lopt = tp->listen_opt; | 901 | struct listen_sock *lopt = tp->accept_queue.listen_opt; |
| 900 | u32 h = tcp_v4_synq_hash(req->af.v4_req.rmt_addr, req->rmt_port, lopt->hash_rnd); | 902 | u32 h = tcp_v4_synq_hash(inet_rsk(req)->rmt_addr, inet_rsk(req)->rmt_port, lopt->hash_rnd); |
| 901 | |||
| 902 | req->expires = jiffies + TCP_TIMEOUT_INIT; | ||
| 903 | req->retrans = 0; | ||
| 904 | req->sk = NULL; | ||
| 905 | req->dl_next = lopt->syn_table[h]; | ||
| 906 | |||
| 907 | write_lock(&tp->syn_wait_lock); | ||
| 908 | lopt->syn_table[h] = req; | ||
| 909 | write_unlock(&tp->syn_wait_lock); | ||
| 910 | 903 | ||
| 904 | reqsk_queue_hash_req(&tp->accept_queue, h, req, TCP_TIMEOUT_INIT); | ||
| 911 | tcp_synq_added(sk); | 905 | tcp_synq_added(sk); |
| 912 | } | 906 | } |
| 913 | 907 | ||
| @@ -1050,7 +1044,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info) | |||
| 1050 | } | 1044 | } |
| 1051 | 1045 | ||
| 1052 | switch (sk->sk_state) { | 1046 | switch (sk->sk_state) { |
| 1053 | struct open_request *req, **prev; | 1047 | struct request_sock *req, **prev; |
| 1054 | case TCP_LISTEN: | 1048 | case TCP_LISTEN: |
| 1055 | if (sock_owned_by_user(sk)) | 1049 | if (sock_owned_by_user(sk)) |
| 1056 | goto out; | 1050 | goto out; |
| @@ -1065,7 +1059,7 @@ void tcp_v4_err(struct sk_buff *skb, u32 info) | |||
| 1065 | */ | 1059 | */ |
| 1066 | BUG_TRAP(!req->sk); | 1060 | BUG_TRAP(!req->sk); |
| 1067 | 1061 | ||
| 1068 | if (seq != req->snt_isn) { | 1062 | if (seq != tcp_rsk(req)->snt_isn) { |
| 1069 | NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); | 1063 | NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); |
| 1070 | goto out; | 1064 | goto out; |
| 1071 | } | 1065 | } |
| @@ -1254,28 +1248,29 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
| 1254 | tcp_tw_put(tw); | 1248 | tcp_tw_put(tw); |
| 1255 | } | 1249 | } |
| 1256 | 1250 | ||
| 1257 | static void tcp_v4_or_send_ack(struct sk_buff *skb, struct open_request *req) | 1251 | static void tcp_v4_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) |
| 1258 | { | 1252 | { |
| 1259 | tcp_v4_send_ack(skb, req->snt_isn + 1, req->rcv_isn + 1, req->rcv_wnd, | 1253 | tcp_v4_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, |
| 1260 | req->ts_recent); | 1254 | req->ts_recent); |
| 1261 | } | 1255 | } |
| 1262 | 1256 | ||
| 1263 | static struct dst_entry* tcp_v4_route_req(struct sock *sk, | 1257 | static struct dst_entry* tcp_v4_route_req(struct sock *sk, |
| 1264 | struct open_request *req) | 1258 | struct request_sock *req) |
| 1265 | { | 1259 | { |
| 1266 | struct rtable *rt; | 1260 | struct rtable *rt; |
| 1267 | struct ip_options *opt = req->af.v4_req.opt; | 1261 | const struct inet_request_sock *ireq = inet_rsk(req); |
| 1262 | struct ip_options *opt = inet_rsk(req)->opt; | ||
| 1268 | struct flowi fl = { .oif = sk->sk_bound_dev_if, | 1263 | struct flowi fl = { .oif = sk->sk_bound_dev_if, |
| 1269 | .nl_u = { .ip4_u = | 1264 | .nl_u = { .ip4_u = |
| 1270 | { .daddr = ((opt && opt->srr) ? | 1265 | { .daddr = ((opt && opt->srr) ? |
| 1271 | opt->faddr : | 1266 | opt->faddr : |
| 1272 | req->af.v4_req.rmt_addr), | 1267 | ireq->rmt_addr), |
| 1273 | .saddr = req->af.v4_req.loc_addr, | 1268 | .saddr = ireq->loc_addr, |
| 1274 | .tos = RT_CONN_FLAGS(sk) } }, | 1269 | .tos = RT_CONN_FLAGS(sk) } }, |
| 1275 | .proto = IPPROTO_TCP, | 1270 | .proto = IPPROTO_TCP, |
| 1276 | .uli_u = { .ports = | 1271 | .uli_u = { .ports = |
| 1277 | { .sport = inet_sk(sk)->sport, | 1272 | { .sport = inet_sk(sk)->sport, |
| 1278 | .dport = req->rmt_port } } }; | 1273 | .dport = ireq->rmt_port } } }; |
| 1279 | 1274 | ||
| 1280 | if (ip_route_output_flow(&rt, &fl, sk, 0)) { | 1275 | if (ip_route_output_flow(&rt, &fl, sk, 0)) { |
| 1281 | IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); | 1276 | IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); |
| @@ -1291,12 +1286,13 @@ static struct dst_entry* tcp_v4_route_req(struct sock *sk, | |||
| 1291 | 1286 | ||
| 1292 | /* | 1287 | /* |
| 1293 | * Send a SYN-ACK after having received an ACK. | 1288 | * Send a SYN-ACK after having received an ACK. |
| 1294 | * This still operates on a open_request only, not on a big | 1289 | * This still operates on a request_sock only, not on a big |
| 1295 | * socket. | 1290 | * socket. |
| 1296 | */ | 1291 | */ |
| 1297 | static int tcp_v4_send_synack(struct sock *sk, struct open_request *req, | 1292 | static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req, |
| 1298 | struct dst_entry *dst) | 1293 | struct dst_entry *dst) |
| 1299 | { | 1294 | { |
| 1295 | const struct inet_request_sock *ireq = inet_rsk(req); | ||
| 1300 | int err = -1; | 1296 | int err = -1; |
| 1301 | struct sk_buff * skb; | 1297 | struct sk_buff * skb; |
| 1302 | 1298 | ||
| @@ -1310,14 +1306,14 @@ static int tcp_v4_send_synack(struct sock *sk, struct open_request *req, | |||
| 1310 | struct tcphdr *th = skb->h.th; | 1306 | struct tcphdr *th = skb->h.th; |
| 1311 | 1307 | ||
| 1312 | th->check = tcp_v4_check(th, skb->len, | 1308 | th->check = tcp_v4_check(th, skb->len, |
| 1313 | req->af.v4_req.loc_addr, | 1309 | ireq->loc_addr, |
| 1314 | req->af.v4_req.rmt_addr, | 1310 | ireq->rmt_addr, |
| 1315 | csum_partial((char *)th, skb->len, | 1311 | csum_partial((char *)th, skb->len, |
| 1316 | skb->csum)); | 1312 | skb->csum)); |
| 1317 | 1313 | ||
| 1318 | err = ip_build_and_send_pkt(skb, sk, req->af.v4_req.loc_addr, | 1314 | err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr, |
| 1319 | req->af.v4_req.rmt_addr, | 1315 | ireq->rmt_addr, |
| 1320 | req->af.v4_req.opt); | 1316 | ireq->opt); |
| 1321 | if (err == NET_XMIT_CN) | 1317 | if (err == NET_XMIT_CN) |
| 1322 | err = 0; | 1318 | err = 0; |
| 1323 | } | 1319 | } |
| @@ -1328,12 +1324,12 @@ out: | |||
| 1328 | } | 1324 | } |
| 1329 | 1325 | ||
| 1330 | /* | 1326 | /* |
| 1331 | * IPv4 open_request destructor. | 1327 | * IPv4 request_sock destructor. |
| 1332 | */ | 1328 | */ |
| 1333 | static void tcp_v4_or_free(struct open_request *req) | 1329 | static void tcp_v4_reqsk_destructor(struct request_sock *req) |
| 1334 | { | 1330 | { |
| 1335 | if (req->af.v4_req.opt) | 1331 | if (inet_rsk(req)->opt) |
| 1336 | kfree(req->af.v4_req.opt); | 1332 | kfree(inet_rsk(req)->opt); |
| 1337 | } | 1333 | } |
| 1338 | 1334 | ||
| 1339 | static inline void syn_flood_warning(struct sk_buff *skb) | 1335 | static inline void syn_flood_warning(struct sk_buff *skb) |
| @@ -1349,7 +1345,7 @@ static inline void syn_flood_warning(struct sk_buff *skb) | |||
| 1349 | } | 1345 | } |
| 1350 | 1346 | ||
| 1351 | /* | 1347 | /* |
| 1352 | * Save and compile IPv4 options into the open_request if needed. | 1348 | * Save and compile IPv4 options into the request_sock if needed. |
| 1353 | */ | 1349 | */ |
| 1354 | static inline struct ip_options *tcp_v4_save_options(struct sock *sk, | 1350 | static inline struct ip_options *tcp_v4_save_options(struct sock *sk, |
| 1355 | struct sk_buff *skb) | 1351 | struct sk_buff *skb) |
| @@ -1370,33 +1366,20 @@ static inline struct ip_options *tcp_v4_save_options(struct sock *sk, | |||
| 1370 | return dopt; | 1366 | return dopt; |
| 1371 | } | 1367 | } |
| 1372 | 1368 | ||
| 1373 | /* | 1369 | struct request_sock_ops tcp_request_sock_ops = { |
| 1374 | * Maximum number of SYN_RECV sockets in queue per LISTEN socket. | ||
| 1375 | * One SYN_RECV socket costs about 80bytes on a 32bit machine. | ||
| 1376 | * It would be better to replace it with a global counter for all sockets | ||
| 1377 | * but then some measure against one socket starving all other sockets | ||
| 1378 | * would be needed. | ||
| 1379 | * | ||
| 1380 | * It was 128 by default. Experiments with real servers show, that | ||
| 1381 | * it is absolutely not enough even at 100conn/sec. 256 cures most | ||
| 1382 | * of problems. This value is adjusted to 128 for very small machines | ||
| 1383 | * (<=32Mb of memory) and to 1024 on normal or better ones (>=256Mb). | ||
| 1384 | * Further increasing requires to change hash table size. | ||
| 1385 | */ | ||
| 1386 | int sysctl_max_syn_backlog = 256; | ||
| 1387 | |||
| 1388 | struct or_calltable or_ipv4 = { | ||
| 1389 | .family = PF_INET, | 1370 | .family = PF_INET, |
| 1371 | .obj_size = sizeof(struct tcp_request_sock), | ||
| 1390 | .rtx_syn_ack = tcp_v4_send_synack, | 1372 | .rtx_syn_ack = tcp_v4_send_synack, |
| 1391 | .send_ack = tcp_v4_or_send_ack, | 1373 | .send_ack = tcp_v4_reqsk_send_ack, |
| 1392 | .destructor = tcp_v4_or_free, | 1374 | .destructor = tcp_v4_reqsk_destructor, |
| 1393 | .send_reset = tcp_v4_send_reset, | 1375 | .send_reset = tcp_v4_send_reset, |
| 1394 | }; | 1376 | }; |
| 1395 | 1377 | ||
| 1396 | int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | 1378 | int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) |
| 1397 | { | 1379 | { |
| 1380 | struct inet_request_sock *ireq; | ||
| 1398 | struct tcp_options_received tmp_opt; | 1381 | struct tcp_options_received tmp_opt; |
| 1399 | struct open_request *req; | 1382 | struct request_sock *req; |
| 1400 | __u32 saddr = skb->nh.iph->saddr; | 1383 | __u32 saddr = skb->nh.iph->saddr; |
| 1401 | __u32 daddr = skb->nh.iph->daddr; | 1384 | __u32 daddr = skb->nh.iph->daddr; |
| 1402 | __u32 isn = TCP_SKB_CB(skb)->when; | 1385 | __u32 isn = TCP_SKB_CB(skb)->when; |
| @@ -1433,7 +1416,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1433 | if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1) | 1416 | if (sk_acceptq_is_full(sk) && tcp_synq_young(sk) > 1) |
| 1434 | goto drop; | 1417 | goto drop; |
| 1435 | 1418 | ||
| 1436 | req = tcp_openreq_alloc(); | 1419 | req = reqsk_alloc(&tcp_request_sock_ops); |
| 1437 | if (!req) | 1420 | if (!req) |
| 1438 | goto drop; | 1421 | goto drop; |
| 1439 | 1422 | ||
| @@ -1461,10 +1444,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1461 | 1444 | ||
| 1462 | tcp_openreq_init(req, &tmp_opt, skb); | 1445 | tcp_openreq_init(req, &tmp_opt, skb); |
| 1463 | 1446 | ||
| 1464 | req->af.v4_req.loc_addr = daddr; | 1447 | ireq = inet_rsk(req); |
| 1465 | req->af.v4_req.rmt_addr = saddr; | 1448 | ireq->loc_addr = daddr; |
| 1466 | req->af.v4_req.opt = tcp_v4_save_options(sk, skb); | 1449 | ireq->rmt_addr = saddr; |
| 1467 | req->class = &or_ipv4; | 1450 | ireq->opt = tcp_v4_save_options(sk, skb); |
| 1468 | if (!want_cookie) | 1451 | if (!want_cookie) |
| 1469 | TCP_ECN_create_request(req, skb->h.th); | 1452 | TCP_ECN_create_request(req, skb->h.th); |
| 1470 | 1453 | ||
| @@ -1523,20 +1506,20 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1523 | 1506 | ||
| 1524 | isn = tcp_v4_init_sequence(sk, skb); | 1507 | isn = tcp_v4_init_sequence(sk, skb); |
| 1525 | } | 1508 | } |
| 1526 | req->snt_isn = isn; | 1509 | tcp_rsk(req)->snt_isn = isn; |
| 1527 | 1510 | ||
| 1528 | if (tcp_v4_send_synack(sk, req, dst)) | 1511 | if (tcp_v4_send_synack(sk, req, dst)) |
| 1529 | goto drop_and_free; | 1512 | goto drop_and_free; |
| 1530 | 1513 | ||
| 1531 | if (want_cookie) { | 1514 | if (want_cookie) { |
| 1532 | tcp_openreq_free(req); | 1515 | reqsk_free(req); |
| 1533 | } else { | 1516 | } else { |
| 1534 | tcp_v4_synq_add(sk, req); | 1517 | tcp_v4_synq_add(sk, req); |
| 1535 | } | 1518 | } |
| 1536 | return 0; | 1519 | return 0; |
| 1537 | 1520 | ||
| 1538 | drop_and_free: | 1521 | drop_and_free: |
| 1539 | tcp_openreq_free(req); | 1522 | reqsk_free(req); |
| 1540 | drop: | 1523 | drop: |
| 1541 | TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS); | 1524 | TCP_INC_STATS_BH(TCP_MIB_ATTEMPTFAILS); |
| 1542 | return 0; | 1525 | return 0; |
| @@ -1548,9 +1531,10 @@ drop: | |||
| 1548 | * now create the new socket. | 1531 | * now create the new socket. |
| 1549 | */ | 1532 | */ |
| 1550 | struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | 1533 | struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, |
| 1551 | struct open_request *req, | 1534 | struct request_sock *req, |
| 1552 | struct dst_entry *dst) | 1535 | struct dst_entry *dst) |
| 1553 | { | 1536 | { |
| 1537 | struct inet_request_sock *ireq; | ||
| 1554 | struct inet_sock *newinet; | 1538 | struct inet_sock *newinet; |
| 1555 | struct tcp_sock *newtp; | 1539 | struct tcp_sock *newtp; |
| 1556 | struct sock *newsk; | 1540 | struct sock *newsk; |
| @@ -1570,11 +1554,12 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
| 1570 | 1554 | ||
| 1571 | newtp = tcp_sk(newsk); | 1555 | newtp = tcp_sk(newsk); |
| 1572 | newinet = inet_sk(newsk); | 1556 | newinet = inet_sk(newsk); |
| 1573 | newinet->daddr = req->af.v4_req.rmt_addr; | 1557 | ireq = inet_rsk(req); |
| 1574 | newinet->rcv_saddr = req->af.v4_req.loc_addr; | 1558 | newinet->daddr = ireq->rmt_addr; |
| 1575 | newinet->saddr = req->af.v4_req.loc_addr; | 1559 | newinet->rcv_saddr = ireq->loc_addr; |
| 1576 | newinet->opt = req->af.v4_req.opt; | 1560 | newinet->saddr = ireq->loc_addr; |
| 1577 | req->af.v4_req.opt = NULL; | 1561 | newinet->opt = ireq->opt; |
| 1562 | ireq->opt = NULL; | ||
| 1578 | newinet->mc_index = tcp_v4_iif(skb); | 1563 | newinet->mc_index = tcp_v4_iif(skb); |
| 1579 | newinet->mc_ttl = skb->nh.iph->ttl; | 1564 | newinet->mc_ttl = skb->nh.iph->ttl; |
| 1580 | newtp->ext_header_len = 0; | 1565 | newtp->ext_header_len = 0; |
| @@ -1605,9 +1590,9 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) | |||
| 1605 | struct iphdr *iph = skb->nh.iph; | 1590 | struct iphdr *iph = skb->nh.iph; |
| 1606 | struct tcp_sock *tp = tcp_sk(sk); | 1591 | struct tcp_sock *tp = tcp_sk(sk); |
| 1607 | struct sock *nsk; | 1592 | struct sock *nsk; |
| 1608 | struct open_request **prev; | 1593 | struct request_sock **prev; |
| 1609 | /* Find possible connection requests. */ | 1594 | /* Find possible connection requests. */ |
| 1610 | struct open_request *req = tcp_v4_search_req(tp, &prev, th->source, | 1595 | struct request_sock *req = tcp_v4_search_req(tp, &prev, th->source, |
| 1611 | iph->saddr, iph->daddr); | 1596 | iph->saddr, iph->daddr); |
| 1612 | if (req) | 1597 | if (req) |
| 1613 | return tcp_check_req(sk, skb, req, prev); | 1598 | return tcp_check_req(sk, skb, req, prev); |
| @@ -2144,13 +2129,13 @@ static void *listening_get_next(struct seq_file *seq, void *cur) | |||
| 2144 | ++st->num; | 2129 | ++st->num; |
| 2145 | 2130 | ||
| 2146 | if (st->state == TCP_SEQ_STATE_OPENREQ) { | 2131 | if (st->state == TCP_SEQ_STATE_OPENREQ) { |
| 2147 | struct open_request *req = cur; | 2132 | struct request_sock *req = cur; |
| 2148 | 2133 | ||
| 2149 | tp = tcp_sk(st->syn_wait_sk); | 2134 | tp = tcp_sk(st->syn_wait_sk); |
| 2150 | req = req->dl_next; | 2135 | req = req->dl_next; |
| 2151 | while (1) { | 2136 | while (1) { |
| 2152 | while (req) { | 2137 | while (req) { |
| 2153 | if (req->class->family == st->family) { | 2138 | if (req->rsk_ops->family == st->family) { |
| 2154 | cur = req; | 2139 | cur = req; |
| 2155 | goto out; | 2140 | goto out; |
| 2156 | } | 2141 | } |
| @@ -2159,17 +2144,17 @@ static void *listening_get_next(struct seq_file *seq, void *cur) | |||
| 2159 | if (++st->sbucket >= TCP_SYNQ_HSIZE) | 2144 | if (++st->sbucket >= TCP_SYNQ_HSIZE) |
| 2160 | break; | 2145 | break; |
| 2161 | get_req: | 2146 | get_req: |
| 2162 | req = tp->listen_opt->syn_table[st->sbucket]; | 2147 | req = tp->accept_queue.listen_opt->syn_table[st->sbucket]; |
| 2163 | } | 2148 | } |
| 2164 | sk = sk_next(st->syn_wait_sk); | 2149 | sk = sk_next(st->syn_wait_sk); |
| 2165 | st->state = TCP_SEQ_STATE_LISTENING; | 2150 | st->state = TCP_SEQ_STATE_LISTENING; |
| 2166 | read_unlock_bh(&tp->syn_wait_lock); | 2151 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
| 2167 | } else { | 2152 | } else { |
| 2168 | tp = tcp_sk(sk); | 2153 | tp = tcp_sk(sk); |
| 2169 | read_lock_bh(&tp->syn_wait_lock); | 2154 | read_lock_bh(&tp->accept_queue.syn_wait_lock); |
| 2170 | if (tp->listen_opt && tp->listen_opt->qlen) | 2155 | if (reqsk_queue_len(&tp->accept_queue)) |
| 2171 | goto start_req; | 2156 | goto start_req; |
| 2172 | read_unlock_bh(&tp->syn_wait_lock); | 2157 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
| 2173 | sk = sk_next(sk); | 2158 | sk = sk_next(sk); |
| 2174 | } | 2159 | } |
| 2175 | get_sk: | 2160 | get_sk: |
| @@ -2179,8 +2164,8 @@ get_sk: | |||
| 2179 | goto out; | 2164 | goto out; |
| 2180 | } | 2165 | } |
| 2181 | tp = tcp_sk(sk); | 2166 | tp = tcp_sk(sk); |
| 2182 | read_lock_bh(&tp->syn_wait_lock); | 2167 | read_lock_bh(&tp->accept_queue.syn_wait_lock); |
| 2183 | if (tp->listen_opt && tp->listen_opt->qlen) { | 2168 | if (reqsk_queue_len(&tp->accept_queue)) { |
| 2184 | start_req: | 2169 | start_req: |
| 2185 | st->uid = sock_i_uid(sk); | 2170 | st->uid = sock_i_uid(sk); |
| 2186 | st->syn_wait_sk = sk; | 2171 | st->syn_wait_sk = sk; |
| @@ -2188,7 +2173,7 @@ start_req: | |||
| 2188 | st->sbucket = 0; | 2173 | st->sbucket = 0; |
| 2189 | goto get_req; | 2174 | goto get_req; |
| 2190 | } | 2175 | } |
| 2191 | read_unlock_bh(&tp->syn_wait_lock); | 2176 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
| 2192 | } | 2177 | } |
| 2193 | if (++st->bucket < TCP_LHTABLE_SIZE) { | 2178 | if (++st->bucket < TCP_LHTABLE_SIZE) { |
| 2194 | sk = sk_head(&tcp_listening_hash[st->bucket]); | 2179 | sk = sk_head(&tcp_listening_hash[st->bucket]); |
| @@ -2375,7 +2360,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v) | |||
| 2375 | case TCP_SEQ_STATE_OPENREQ: | 2360 | case TCP_SEQ_STATE_OPENREQ: |
| 2376 | if (v) { | 2361 | if (v) { |
| 2377 | struct tcp_sock *tp = tcp_sk(st->syn_wait_sk); | 2362 | struct tcp_sock *tp = tcp_sk(st->syn_wait_sk); |
| 2378 | read_unlock_bh(&tp->syn_wait_lock); | 2363 | read_unlock_bh(&tp->accept_queue.syn_wait_lock); |
| 2379 | } | 2364 | } |
| 2380 | case TCP_SEQ_STATE_LISTENING: | 2365 | case TCP_SEQ_STATE_LISTENING: |
| 2381 | if (v != SEQ_START_TOKEN) | 2366 | if (v != SEQ_START_TOKEN) |
| @@ -2451,18 +2436,19 @@ void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo) | |||
| 2451 | memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); | 2436 | memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); |
| 2452 | } | 2437 | } |
| 2453 | 2438 | ||
| 2454 | static void get_openreq4(struct sock *sk, struct open_request *req, | 2439 | static void get_openreq4(struct sock *sk, struct request_sock *req, |
| 2455 | char *tmpbuf, int i, int uid) | 2440 | char *tmpbuf, int i, int uid) |
| 2456 | { | 2441 | { |
| 2442 | const struct inet_request_sock *ireq = inet_rsk(req); | ||
| 2457 | int ttd = req->expires - jiffies; | 2443 | int ttd = req->expires - jiffies; |
| 2458 | 2444 | ||
| 2459 | sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" | 2445 | sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" |
| 2460 | " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p", | 2446 | " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p", |
| 2461 | i, | 2447 | i, |
| 2462 | req->af.v4_req.loc_addr, | 2448 | ireq->loc_addr, |
| 2463 | ntohs(inet_sk(sk)->sport), | 2449 | ntohs(inet_sk(sk)->sport), |
| 2464 | req->af.v4_req.rmt_addr, | 2450 | ireq->rmt_addr, |
| 2465 | ntohs(req->rmt_port), | 2451 | ntohs(ireq->rmt_port), |
| 2466 | TCP_SYN_RECV, | 2452 | TCP_SYN_RECV, |
| 2467 | 0, 0, /* could print option size, but that is af dependent. */ | 2453 | 0, 0, /* could print option size, but that is af dependent. */ |
| 2468 | 1, /* timers active (only the expire timer) */ | 2454 | 1, /* timers active (only the expire timer) */ |
| @@ -2618,6 +2604,7 @@ struct proto tcp_prot = { | |||
| 2618 | .sysctl_rmem = sysctl_tcp_rmem, | 2604 | .sysctl_rmem = sysctl_tcp_rmem, |
| 2619 | .max_header = MAX_TCP_HEADER, | 2605 | .max_header = MAX_TCP_HEADER, |
| 2620 | .obj_size = sizeof(struct tcp_sock), | 2606 | .obj_size = sizeof(struct tcp_sock), |
| 2607 | .rsk_prot = &tcp_request_sock_ops, | ||
| 2621 | }; | 2608 | }; |
| 2622 | 2609 | ||
| 2623 | 2610 | ||
| @@ -2660,7 +2647,6 @@ EXPORT_SYMBOL(tcp_proc_register); | |||
| 2660 | EXPORT_SYMBOL(tcp_proc_unregister); | 2647 | EXPORT_SYMBOL(tcp_proc_unregister); |
| 2661 | #endif | 2648 | #endif |
| 2662 | EXPORT_SYMBOL(sysctl_local_port_range); | 2649 | EXPORT_SYMBOL(sysctl_local_port_range); |
| 2663 | EXPORT_SYMBOL(sysctl_max_syn_backlog); | ||
| 2664 | EXPORT_SYMBOL(sysctl_tcp_low_latency); | 2650 | EXPORT_SYMBOL(sysctl_tcp_low_latency); |
| 2665 | EXPORT_SYMBOL(sysctl_tcp_tw_reuse); | 2651 | EXPORT_SYMBOL(sysctl_tcp_tw_reuse); |
| 2666 | 2652 | ||
