tcp_ipv6.c (d8a382d2662822248a97ce9d670b90e68aefbd3a) tcp_ipv6.c (af9b4738574b46025de7ccbe75c7b24fd8914379)
1/*
2 * TCP over IPv6
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * Based on:

--- 115 unchanged lines hidden (view full) ---

124static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
125 int addr_len)
126{
127 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
128 struct inet_sock *inet = inet_sk(sk);
129 struct inet_connection_sock *icsk = inet_csk(sk);
130 struct ipv6_pinfo *np = inet6_sk(sk);
131 struct tcp_sock *tp = tcp_sk(sk);
1/*
2 * TCP over IPv6
3 * Linux INET6 implementation
4 *
5 * Authors:
6 * Pedro Roque <roque@di.fc.ul.pt>
7 *
8 * Based on:

--- 115 unchanged lines hidden (view full) ---

124static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
125 int addr_len)
126{
127 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
128 struct inet_sock *inet = inet_sk(sk);
129 struct inet_connection_sock *icsk = inet_csk(sk);
130 struct ipv6_pinfo *np = inet6_sk(sk);
131 struct tcp_sock *tp = tcp_sk(sk);
132 struct in6_addr *saddr = NULL, *final_p = NULL, final;
132 struct in6_addr *saddr = NULL, *final_p, final;
133 struct flowi fl;
134 struct dst_entry *dst;
135 int addr_type;
136 int err;
137
138 if (addr_len < SIN6_LEN_RFC2133)
139 return -EINVAL;
140

--- 104 unchanged lines hidden (view full) ---

245 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
246 ipv6_addr_copy(&fl.fl6_src,
247 (saddr ? saddr : &np->saddr));
248 fl.oif = sk->sk_bound_dev_if;
249 fl.mark = sk->sk_mark;
250 fl.fl_ip_dport = usin->sin6_port;
251 fl.fl_ip_sport = inet->inet_sport;
252
133 struct flowi fl;
134 struct dst_entry *dst;
135 int addr_type;
136 int err;
137
138 if (addr_len < SIN6_LEN_RFC2133)
139 return -EINVAL;
140

--- 104 unchanged lines hidden (view full) ---

245 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
246 ipv6_addr_copy(&fl.fl6_src,
247 (saddr ? saddr : &np->saddr));
248 fl.oif = sk->sk_bound_dev_if;
249 fl.mark = sk->sk_mark;
250 fl.fl_ip_dport = usin->sin6_port;
251 fl.fl_ip_sport = inet->inet_sport;
252
253 if (np->opt && np->opt->srcrt) {
254 struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
255 ipv6_addr_copy(&final, &fl.fl6_dst);
256 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
257 final_p = &final;
258 }
253 final_p = fl6_update_dst(&fl, np->opt, &final);
259
260 security_sk_classify_flow(sk, &fl);
261
262 err = ip6_dst_lookup(sk, &dst, &fl);
263 if (err)
264 goto failure;
265 if (final_p)
266 ipv6_addr_copy(&fl.fl6_dst, final_p);

--- 205 unchanged lines hidden (view full) ---

472
473static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
474 struct request_values *rvp)
475{
476 struct inet6_request_sock *treq = inet6_rsk(req);
477 struct ipv6_pinfo *np = inet6_sk(sk);
478 struct sk_buff * skb;
479 struct ipv6_txoptions *opt = NULL;
254
255 security_sk_classify_flow(sk, &fl);
256
257 err = ip6_dst_lookup(sk, &dst, &fl);
258 if (err)
259 goto failure;
260 if (final_p)
261 ipv6_addr_copy(&fl.fl6_dst, final_p);

--- 205 unchanged lines hidden (view full) ---

467
468static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
469 struct request_values *rvp)
470{
471 struct inet6_request_sock *treq = inet6_rsk(req);
472 struct ipv6_pinfo *np = inet6_sk(sk);
473 struct sk_buff * skb;
474 struct ipv6_txoptions *opt = NULL;
480 struct in6_addr * final_p = NULL, final;
475 struct in6_addr * final_p, final;
481 struct flowi fl;
482 struct dst_entry *dst;
483 int err = -1;
484
485 memset(&fl, 0, sizeof(fl));
486 fl.proto = IPPROTO_TCP;
487 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr);
488 ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
489 fl.fl6_flowlabel = 0;
490 fl.oif = treq->iif;
491 fl.mark = sk->sk_mark;
492 fl.fl_ip_dport = inet_rsk(req)->rmt_port;
493 fl.fl_ip_sport = inet_rsk(req)->loc_port;
494 security_req_classify_flow(req, &fl);
495
496 opt = np->opt;
476 struct flowi fl;
477 struct dst_entry *dst;
478 int err = -1;
479
480 memset(&fl, 0, sizeof(fl));
481 fl.proto = IPPROTO_TCP;
482 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr);
483 ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
484 fl.fl6_flowlabel = 0;
485 fl.oif = treq->iif;
486 fl.mark = sk->sk_mark;
487 fl.fl_ip_dport = inet_rsk(req)->rmt_port;
488 fl.fl_ip_sport = inet_rsk(req)->loc_port;
489 security_req_classify_flow(req, &fl);
490
491 opt = np->opt;
497 if (opt && opt->srcrt) {
498 struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
499 ipv6_addr_copy(&final, &fl.fl6_dst);
500 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
501 final_p = &final;
502 }
492 final_p = fl6_update_dst(&fl, opt, &final);
503
504 err = ip6_dst_lookup(sk, &dst, &fl);
505 if (err)
506 goto done;
507 if (final_p)
508 ipv6_addr_copy(&fl.fl6_dst, final_p);
509 if ((err = xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0)
510 goto done;

--- 651 unchanged lines hidden (view full) ---

1162 bh_lock_sock(nsk);
1163 return nsk;
1164 }
1165 inet_twsk_put(inet_twsk(nsk));
1166 return NULL;
1167 }
1168
1169#ifdef CONFIG_SYN_COOKIES
493
494 err = ip6_dst_lookup(sk, &dst, &fl);
495 if (err)
496 goto done;
497 if (final_p)
498 ipv6_addr_copy(&fl.fl6_dst, final_p);
499 if ((err = xfrm_lookup(sock_net(sk), &dst, &fl, sk, 0)) < 0)
500 goto done;

--- 651 unchanged lines hidden (view full) ---

1152 bh_lock_sock(nsk);
1153 return nsk;
1154 }
1155 inet_twsk_put(inet_twsk(nsk));
1156 return NULL;
1157 }
1158
1159#ifdef CONFIG_SYN_COOKIES
1170 if (!th->rst && !th->syn && th->ack)
1160 if (!th->syn)
1171 sk = cookie_v6_check(sk, skb);
1172#endif
1173 return sk;
1174}
1175
1176/* FIXME: this is substantially similar to the ipv4 code.
1177 * Can some kind of merge be done? -- erics
1178 */

--- 208 unchanged lines hidden (view full) ---

1387
1388 treq = inet6_rsk(req);
1389 opt = np->opt;
1390
1391 if (sk_acceptq_is_full(sk))
1392 goto out_overflow;
1393
1394 if (dst == NULL) {
1161 sk = cookie_v6_check(sk, skb);
1162#endif
1163 return sk;
1164}
1165
1166/* FIXME: this is substantially similar to the ipv4 code.
1167 * Can some kind of merge be done? -- erics
1168 */

--- 208 unchanged lines hidden (view full) ---

1377
1378 treq = inet6_rsk(req);
1379 opt = np->opt;
1380
1381 if (sk_acceptq_is_full(sk))
1382 goto out_overflow;
1383
1384 if (dst == NULL) {
1395 struct in6_addr *final_p = NULL, final;
1385 struct in6_addr *final_p, final;
1396 struct flowi fl;
1397
1398 memset(&fl, 0, sizeof(fl));
1399 fl.proto = IPPROTO_TCP;
1400 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr);
1386 struct flowi fl;
1387
1388 memset(&fl, 0, sizeof(fl));
1389 fl.proto = IPPROTO_TCP;
1390 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr);
1401 if (opt && opt->srcrt) {
1402 struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt;
1403 ipv6_addr_copy(&final, &fl.fl6_dst);
1404 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
1405 final_p = &final;
1406 }
1391 final_p = fl6_update_dst(&fl, opt, &final);
1407 ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
1408 fl.oif = sk->sk_bound_dev_if;
1409 fl.mark = sk->sk_mark;
1410 fl.fl_ip_dport = inet_rsk(req)->rmt_port;
1411 fl.fl_ip_sport = inet_rsk(req)->loc_port;
1412 security_req_classify_flow(req, &fl);
1413
1414 if (ip6_dst_lookup(sk, &dst, &fl))

--- 842 unchanged lines hidden ---
1392 ipv6_addr_copy(&fl.fl6_src, &treq->loc_addr);
1393 fl.oif = sk->sk_bound_dev_if;
1394 fl.mark = sk->sk_mark;
1395 fl.fl_ip_dport = inet_rsk(req)->rmt_port;
1396 fl.fl_ip_sport = inet_rsk(req)->loc_port;
1397 security_req_classify_flow(req, &fl);
1398
1399 if (ip6_dst_lookup(sk, &dst, &fl))

--- 842 unchanged lines hidden ---