Lines Matching +full:input +full:- +full:sel
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C)2003-2006 Helsinki University of Technology
4 * Copyright (C)2003-2006 USAGI/WIDE Project
28 return (n - len + 16) & 0x7; in calc_padlen()
39 data[1] = padlen - 2; in mip6_padn()
82 return -1; in mip6_mh_filter()
84 if (((mh->ip6mh_hdrlen + 1) << 3) > skb->len) in mip6_mh_filter()
85 return -1; in mip6_mh_filter()
87 if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) { in mip6_mh_filter()
89 mh->ip6mh_hdrlen, in mip6_mh_filter()
90 mip6_mh_len(mh->ip6mh_type)); in mip6_mh_filter()
93 return -1; in mip6_mh_filter()
96 if (mh->ip6mh_proto != IPPROTO_NONE) { in mip6_mh_filter()
98 mh->ip6mh_proto); in mip6_mh_filter()
101 return -1; in mip6_mh_filter()
122 struct ipv6_destopt_hdr *destopt = (struct ipv6_destopt_hdr *)skb->data; in mip6_destopt_input()
123 int err = destopt->nexthdr; in mip6_destopt_input()
125 spin_lock(&x->lock); in mip6_destopt_input()
126 if (!ipv6_addr_equal(&iph->saddr, (struct in6_addr *)x->coaddr) && in mip6_destopt_input()
127 !ipv6_addr_any((struct in6_addr *)x->coaddr)) in mip6_destopt_input()
128 err = -ENOENT; in mip6_destopt_input()
129 spin_unlock(&x->lock); in mip6_destopt_input()
146 skb_push(skb, -skb_network_offset(skb)); in mip6_destopt_output()
153 dstopt->nexthdr = nexthdr; in mip6_destopt_output()
158 hao->type = IPV6_TLV_HAO; in mip6_destopt_output()
160 hao->length = sizeof(*hao) - 2; in mip6_destopt_output()
162 len = ((char *)hao - (char *)dstopt) + sizeof(*hao); in mip6_destopt_output()
164 memcpy(&hao->addr, &iph->saddr, sizeof(hao->addr)); in mip6_destopt_output()
165 spin_lock_bh(&x->lock); in mip6_destopt_output()
166 memcpy(&iph->saddr, x->coaddr, sizeof(iph->saddr)); in mip6_destopt_output()
167 spin_unlock_bh(&x->lock); in mip6_destopt_output()
169 WARN_ON(len != x->props.header_len); in mip6_destopt_output()
170 dstopt->hdrlen = (x->props.header_len >> 3) - 1; in mip6_destopt_output()
200 struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb; in mip6_destopt_reject()
201 const struct flowi6 *fl6 = &fl->u.ip6; in mip6_destopt_reject()
203 struct xfrm_selector sel; in mip6_destopt_reject() local
208 if (unlikely(fl6->flowi6_proto == IPPROTO_MH && in mip6_destopt_reject()
209 fl6->fl6_mh_type <= IP6_MH_TYPE_MAX)) in mip6_destopt_reject()
212 if (likely(opt->dsthao)) { in mip6_destopt_reject()
213 offset = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO); in mip6_destopt_reject()
221 if (!mip6_report_rl_allow(stamp, &ipv6_hdr(skb)->daddr, in mip6_destopt_reject()
222 hao ? &hao->addr : &ipv6_hdr(skb)->saddr, in mip6_destopt_reject()
223 opt->iif)) in mip6_destopt_reject()
226 memset(&sel, 0, sizeof(sel)); in mip6_destopt_reject()
227 memcpy(&sel.daddr, (xfrm_address_t *)&ipv6_hdr(skb)->daddr, in mip6_destopt_reject()
228 sizeof(sel.daddr)); in mip6_destopt_reject()
229 sel.prefixlen_d = 128; in mip6_destopt_reject()
230 memcpy(&sel.saddr, (xfrm_address_t *)&ipv6_hdr(skb)->saddr, in mip6_destopt_reject()
231 sizeof(sel.saddr)); in mip6_destopt_reject()
232 sel.prefixlen_s = 128; in mip6_destopt_reject()
233 sel.family = AF_INET6; in mip6_destopt_reject()
234 sel.proto = fl6->flowi6_proto; in mip6_destopt_reject()
235 sel.dport = xfrm_flowi_dport(fl, &fl6->uli); in mip6_destopt_reject()
236 if (sel.dport) in mip6_destopt_reject()
237 sel.dport_mask = htons(~0); in mip6_destopt_reject()
238 sel.sport = xfrm_flowi_sport(fl, &fl6->uli); in mip6_destopt_reject()
239 if (sel.sport) in mip6_destopt_reject()
240 sel.sport_mask = htons(~0); in mip6_destopt_reject()
241 sel.ifindex = fl6->flowi6_oif; in mip6_destopt_reject()
243 err = km_report(net, IPPROTO_DSTOPTS, &sel, in mip6_destopt_reject()
244 (hao ? (xfrm_address_t *)&hao->addr : NULL)); in mip6_destopt_reject()
252 if (x->id.spi) { in mip6_destopt_init_state()
254 return -EINVAL; in mip6_destopt_init_state()
256 if (x->props.mode != XFRM_MODE_ROUTEOPTIMIZATION) { in mip6_destopt_init_state()
258 return -EINVAL; in mip6_destopt_init_state()
261 x->props.header_len = sizeof(struct ipv6_destopt_hdr) + in mip6_destopt_init_state()
264 WARN_ON(x->props.header_len != 24); in mip6_destopt_init_state()
283 .input = mip6_destopt_input,
291 struct rt2_hdr *rt2 = (struct rt2_hdr *)skb->data; in mip6_rthdr_input()
292 int err = rt2->rt_hdr.nexthdr; in mip6_rthdr_input()
294 spin_lock(&x->lock); in mip6_rthdr_input()
295 if (!ipv6_addr_equal(&iph->daddr, (struct in6_addr *)x->coaddr) && in mip6_rthdr_input()
296 !ipv6_addr_any((struct in6_addr *)x->coaddr)) in mip6_rthdr_input()
297 err = -ENOENT; in mip6_rthdr_input()
298 spin_unlock(&x->lock); in mip6_rthdr_input()
312 skb_push(skb, -skb_network_offset(skb)); in mip6_rthdr_output()
319 rt2->rt_hdr.nexthdr = nexthdr; in mip6_rthdr_output()
320 rt2->rt_hdr.hdrlen = (x->props.header_len >> 3) - 1; in mip6_rthdr_output()
321 rt2->rt_hdr.type = IPV6_SRCRT_TYPE_2; in mip6_rthdr_output()
322 rt2->rt_hdr.segments_left = 1; in mip6_rthdr_output()
323 memset(&rt2->reserved, 0, sizeof(rt2->reserved)); in mip6_rthdr_output()
325 WARN_ON(rt2->rt_hdr.hdrlen != 2); in mip6_rthdr_output()
327 memcpy(&rt2->addr, &iph->daddr, sizeof(rt2->addr)); in mip6_rthdr_output()
328 spin_lock_bh(&x->lock); in mip6_rthdr_output()
329 memcpy(&iph->daddr, x->coaddr, sizeof(iph->daddr)); in mip6_rthdr_output()
330 spin_unlock_bh(&x->lock); in mip6_rthdr_output()
337 if (x->id.spi) { in mip6_rthdr_init_state()
339 return -EINVAL; in mip6_rthdr_init_state()
341 if (x->props.mode != XFRM_MODE_ROUTEOPTIMIZATION) { in mip6_rthdr_init_state()
343 return -EINVAL; in mip6_rthdr_init_state()
346 x->props.header_len = sizeof(struct rt2_hdr); in mip6_rthdr_init_state()
365 .input = mip6_rthdr_input,
394 return -EAGAIN; in mip6_init()