51 #include <linux/types.h>
52 #include <linux/list.h>
53 #include <linux/socket.h>
55 #include <linux/time.h>
56 #include <linux/slab.h>
68 static int sctp_rcv_ootb(
struct sk_buff *);
88 struct sctphdr *sh = sctp_hdr(skb);
92 __u32 tmp = sctp_start_cksum((
__u8 *)sh, skb_headlen(skb));
94 skb_walk_frags(skb, list)
95 tmp = sctp_update_cksum((
__u8 *)list->
data, skb_headlen(list),
98 val = sctp_end_cksum(tmp);
111 #if IS_ENABLED(CONFIG_IPV6)
117 #define SCTP_INPUT_CB(__skb) ((struct sctp_input_cb *)&((__skb)->cb[0]))
135 struct net *net = dev_net(skb->
dev);
142 if (skb_linearize(skb))
148 __skb_pull(skb, skb_transport_offset(skb));
152 sctp_rcv_checksum(net, skb) < 0)
161 family = ipver2af(ip_hdr(skb)->
version);
185 asoc = __sctp_rcv_lookup(net, skb, &src, &dest, &transport);
188 ep = __sctp_rcv_lookup_endpoint(net, &dest);
191 rcvr = asoc ? &asoc->
base : &ep->
base;
198 if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->
skb_iif(skb)))
207 sk = net->sctp.ctl_sock;
208 ep = sctp_sk(sk)->ep;
222 if (sctp_rcv_ootb(skb)) {
224 goto discard_release;
229 goto discard_release;
233 goto discard_release;
238 goto discard_release;
259 if (sk != rcvr->
sk) {
273 if (sctp_add_backlog(sk, skb)) {
277 goto discard_release;
349 if (sk_add_backlog(sk, skb, sk->
sk_rcvbuf))
377 static int sctp_add_backlog(
struct sock *
sk,
struct sk_buff *skb)
383 ret = sk_add_backlog(sk, skb, sk->
sk_rcvbuf);
404 if (!t || (t->
pathmtu <= pmtu))
437 dst = sctp_transport_dst_check(t);
439 dst->
ops->redirect(dst, sk, skb);
469 struct net *net = sock_net(sk);
477 asoc->
state, asoc->
ep, asoc, t,
496 int len = skb->
len - ((
void *)sctphdr - (
void *)skb->
data);
512 asoc = __sctp_lookup_association(net, &saddr, &daddr, &transport);
531 chunkhdr = (
void *)sctphdr +
sizeof(
struct sctphdr);
538 }
else if (vtag != asoc->
c.peer_vtag) {
586 const int ihlen = iph->ihl * 4;
587 const int type = icmp_hdr(skb)->type;
588 const int code = icmp_hdr(skb)->code;
595 struct net *net = dev_net(skb->
dev);
597 if (skb->
len < ihlen + 8) {
605 skb_reset_network_header(skb);
606 skb_set_transport_header(skb, ihlen);
682 static int sctp_rcv_ootb(
struct sk_buff *skb)
696 if (ch_end > skb_tail_pointer(skb))
722 }
while (ch_end < skb_tail_pointer(skb));
733 struct net *net = sock_net(ep->
base.sk);
743 hlist_add_head(&epb->
node, &head->
chain);
751 __sctp_hash_endpoint(ep);
758 struct net *net = sock_net(ep->
base.sk);
769 hlist_del_init(&epb->
node);
777 __sctp_unhash_endpoint(ep);
782 static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(
struct net *net,
791 hash = sctp_ep_hashfn(net,
ntohs(laddr->
v4.sin_port));
800 ep = sctp_sk(net->sctp.ctl_sock)->ep;
811 struct net *net = sock_net(asoc->
base.sk);
824 hlist_add_head(&epb->
node, &head->
chain);
835 __sctp_hash_established(asoc);
842 struct net *net = sock_net(asoc->
base.sk);
854 hlist_del_init(&epb->
node);
865 __sctp_unhash_established(asoc);
886 hash = sctp_assoc_hashfn(net,
ntohs(local->
v4.sin_port),
891 asoc = sctp_assoc(epb);
918 asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
965 struct sctphdr *sh = sctp_hdr(skb);
999 asoc = __sctp_lookup_association(net, laddr, paddr, &transport);
1042 return __sctp_lookup_association(net, laddr, &paddr, transportp);
1063 unsigned int chunk_num = 1;
1076 if (ch_end > skb_tail_pointer(skb))
1081 have_auth = chunk_num;
1092 if (have_auth == 1 && chunk_num == 2)
1097 if (have_auth || net->sctp.addip_noauth)
1098 asoc = __sctp_rcv_asconf_lookup(
1111 }
while (ch_end < skb_tail_pointer(skb));
1143 return __sctp_rcv_init_lookup(net, skb, laddr, transportp);
1147 return __sctp_rcv_walk_lookup(net, skb, laddr, transportp);
1164 asoc = __sctp_lookup_association(net, laddr, paddr, transportp);
1171 asoc = __sctp_rcv_lookup_harder(net, skb, laddr, transportp);