tcp_ipv6.c (50501936288d6a29d7ef78f25d00e33240fad45f) tcp_ipv6.c (5e5265522a9a7f91d1b0bd411d634bdaf16c80cd)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * TCP over IPv6
4 * Linux INET6 implementation
5 *
6 * Authors:
7 * Pedro Roque <roque@di.fc.ul.pt>
8 *

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

88}
89#endif
90
91/* Helper returning the inet6 address from a given tcp socket.
92 * It can be used in TCP stack instead of inet6_sk(sk).
93 * This avoids a dereference and allow compiler optimizations.
94 * It is a specialized version of inet6_sk_generic().
95 */
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * TCP over IPv6
4 * Linux INET6 implementation
5 *
6 * Authors:
7 * Pedro Roque <roque@di.fc.ul.pt>
8 *

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

88}
89#endif
90
91/* Helper returning the inet6 address from a given tcp socket.
92 * It can be used in TCP stack instead of inet6_sk(sk).
93 * This avoids a dereference and allow compiler optimizations.
94 * It is a specialized version of inet6_sk_generic().
95 */
96static struct ipv6_pinfo *tcp_inet6_sk(const struct sock *sk)
97{
98 unsigned int offset = sizeof(struct tcp6_sock) - sizeof(struct ipv6_pinfo);
96#define tcp_inet6_sk(sk) (&container_of_const(tcp_sk(sk), \
97 struct tcp6_sock, tcp)->inet6)
99
98
100 return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
101}
102
103static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
104{
105 struct dst_entry *dst = skb_dst(skb);
106
107 if (dst && dst_hold_safe(dst)) {
108 const struct rt6_info *rt = (const struct rt6_info *)dst;
109
110 rcu_assign_pointer(sk->sk_rx_dst, dst);

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

528static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,
529 struct flowi *fl,
530 struct request_sock *req,
531 struct tcp_fastopen_cookie *foc,
532 enum tcp_synack_type synack_type,
533 struct sk_buff *syn_skb)
534{
535 struct inet_request_sock *ireq = inet_rsk(req);
99static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
100{
101 struct dst_entry *dst = skb_dst(skb);
102
103 if (dst && dst_hold_safe(dst)) {
104 const struct rt6_info *rt = (const struct rt6_info *)dst;
105
106 rcu_assign_pointer(sk->sk_rx_dst, dst);

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

524static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst,
525 struct flowi *fl,
526 struct request_sock *req,
527 struct tcp_fastopen_cookie *foc,
528 enum tcp_synack_type synack_type,
529 struct sk_buff *syn_skb)
530{
531 struct inet_request_sock *ireq = inet_rsk(req);
536 struct ipv6_pinfo *np = tcp_inet6_sk(sk);
532 const struct ipv6_pinfo *np = tcp_inet6_sk(sk);
537 struct ipv6_txoptions *opt;
538 struct flowi6 *fl6 = &fl->u.ip6;
539 struct sk_buff *skb;
540 int err = -ENOMEM;
541 u8 tclass;
542
543 /* First, grab a route. */
544 if (!dst && (dst = inet6_csk_route_req(sk, fl6, req,

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

1128 tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ?
1129 tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,
1130 tcp_rsk(req)->rcv_nxt,
1131 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,
1132 tcp_time_stamp_raw() + tcp_rsk(req)->ts_off,
1133 req->ts_recent, sk->sk_bound_dev_if,
1134 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr, l3index),
1135 ipv6_get_dsfield(ipv6_hdr(skb)), 0, sk->sk_priority,
533 struct ipv6_txoptions *opt;
534 struct flowi6 *fl6 = &fl->u.ip6;
535 struct sk_buff *skb;
536 int err = -ENOMEM;
537 u8 tclass;
538
539 /* First, grab a route. */
540 if (!dst && (dst = inet6_csk_route_req(sk, fl6, req,

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

1124 tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ?
1125 tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,
1126 tcp_rsk(req)->rcv_nxt,
1127 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,
1128 tcp_time_stamp_raw() + tcp_rsk(req)->ts_off,
1129 req->ts_recent, sk->sk_bound_dev_if,
1130 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr, l3index),
1131 ipv6_get_dsfield(ipv6_hdr(skb)), 0, sk->sk_priority,
1136 tcp_rsk(req)->txhash);
1132 READ_ONCE(tcp_rsk(req)->txhash));
1137}
1138
1139
1140static struct sock *tcp_v6_cookie_check(struct sock *sk, struct sk_buff *skb)
1141{
1142#ifdef CONFIG_SYN_COOKIES
1143 const struct tcphdr *th = tcp_hdr(skb);
1144

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

2149 .destroy = tcp_v4_destroy_sock,
2150 .shutdown = tcp_shutdown,
2151 .setsockopt = tcp_setsockopt,
2152 .getsockopt = tcp_getsockopt,
2153 .bpf_bypass_getsockopt = tcp_bpf_bypass_getsockopt,
2154 .keepalive = tcp_set_keepalive,
2155 .recvmsg = tcp_recvmsg,
2156 .sendmsg = tcp_sendmsg,
1133}
1134
1135
1136static struct sock *tcp_v6_cookie_check(struct sock *sk, struct sk_buff *skb)
1137{
1138#ifdef CONFIG_SYN_COOKIES
1139 const struct tcphdr *th = tcp_hdr(skb);
1140

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

2145 .destroy = tcp_v4_destroy_sock,
2146 .shutdown = tcp_shutdown,
2147 .setsockopt = tcp_setsockopt,
2148 .getsockopt = tcp_getsockopt,
2149 .bpf_bypass_getsockopt = tcp_bpf_bypass_getsockopt,
2150 .keepalive = tcp_set_keepalive,
2151 .recvmsg = tcp_recvmsg,
2152 .sendmsg = tcp_sendmsg,
2157 .sendpage = tcp_sendpage,
2153 .splice_eof = tcp_splice_eof,
2158 .backlog_rcv = tcp_v6_do_rcv,
2159 .release_cb = tcp_release_cb,
2160 .hash = inet6_hash,
2161 .unhash = inet_unhash,
2162 .get_port = inet_csk_get_port,
2163 .put_port = inet_put_port,
2164#ifdef CONFIG_BPF_SYSCALL
2165 .psock_update_sk_prot = tcp_bpf_update_proto,

--- 101 unchanged lines hidden ---
2154 .backlog_rcv = tcp_v6_do_rcv,
2155 .release_cb = tcp_release_cb,
2156 .hash = inet6_hash,
2157 .unhash = inet_unhash,
2158 .get_port = inet_csk_get_port,
2159 .put_port = inet_put_port,
2160#ifdef CONFIG_BPF_SYSCALL
2161 .psock_update_sk_prot = tcp_bpf_update_proto,

--- 101 unchanged lines hidden ---