2 * Extension Header handling for IPv6
3 * Linux INET6 implementation
6 * Pedro Roque <roque@di.fc.ul.pt>
7 * Andi Kleen <ak@muc.de>
8 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
17 * yoshfuji : ensure not to overrun while parsing
19 * Mitsuru KANDA @USAGI and: Remove ipv6_parse_exthdrs().
20 * YOSHIFUJI Hideaki @USAGI Register inbound extension header
21 * handlers as inet6_protocol{}.
24 #include <linux/errno.h>
25 #include <linux/types.h>
26 #include <linux/socket.h>
27 #include <linux/sockios.h>
28 #include <linux/net.h>
29 #include <linux/netdevice.h>
30 #include <linux/in6.h>
31 #include <linux/icmpv6.h>
32 #include <linux/slab.h>
33 #include <linux/export.h>
40 #include <net/protocol.h>
41 #include <net/transp_v6.h>
42 #include <net/rawv6.h>
43 #include <net/ndisc.h>
44 #include <net/ip6_route.h>
45 #include <net/addrconf.h>
46 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
50 #include <asm/uaccess.h>
52 int ipv6_find_tlv(struct sk_buff *skb, int offset, int type)
54 const unsigned char *nh = skb_network_header(skb);
55 int packet_len = skb->tail - skb->network_header;
56 struct ipv6_opt_hdr *hdr;
59 if (offset + 2 > packet_len)
61 hdr = (struct ipv6_opt_hdr *)(nh + offset);
62 len = ((hdr->hdrlen + 1) << 3);
64 if (offset + len > packet_len)
71 int opttype = nh[offset];
82 optlen = nh[offset + 1] + 2;
94 EXPORT_SYMBOL_GPL(ipv6_find_tlv);
97 * Parsing tlv encoded headers.
99 * Parsing function "func" returns 1, if parsing succeed
100 * and 0, if it failed.
101 * It MUST NOT touch skb->h.
104 struct tlvtype_proc {
106 int (*func)(struct sk_buff *skb, int offset);
109 /*********************
111 *********************/
113 /* An unknown option is detected, decide what to do */
115 static int ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
117 switch ((skb_network_header(skb)[optoff] & 0xC0) >> 6) {
121 case 1: /* drop packet */
124 case 3: /* Send ICMP if not a multicast address and drop packet */
125 /* Actually, it is redundant check. icmp_send
126 will recheck in any case.
128 if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr))
130 case 2: /* send ICMP PARM PROB regardless and drop packet */
131 icmpv6_param_prob(skb, ICMPV6_UNK_OPTION, optoff);
139 /* Parse tlv encoded option header (hop-by-hop or destination) */
141 static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff *skb)
143 struct tlvtype_proc *curr;
144 const unsigned char *nh = skb_network_header(skb);
145 int off = skb_network_header_len(skb);
146 int len = (skb_transport_header(skb)[1] + 1) << 3;
148 if (skb_transport_offset(skb) + len > skb_headlen(skb))
155 int optlen = nh[off + 1] + 2;
164 /* RFC 2460 states that the purpose of PadN is
165 * to align the containing header to multiples
166 * of 8. 7 is therefore the highest valid value.
167 * See also RFC 4942, Section 2.1.9.5.
171 /* RFC 4942 recommends receiving hosts to
172 * actively check PadN payload to contain
175 for (i = 2; i < optlen; i++) {
176 if (nh[off + i] != 0)
181 default: /* Other TLV code so scan list */
184 for (curr=procs; curr->type >= 0; curr++) {
185 if (curr->type == nh[off]) {
186 /* type specific length/alignment
187 checks will be performed in the
189 if (curr->func(skb, off) == 0)
194 if (curr->type < 0) {
195 if (ip6_tlvopt_unknown(skb, off) == 0)
210 /*****************************
211 Destination options header.
212 *****************************/
214 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
215 static int ipv6_dest_hao(struct sk_buff *skb, int optoff)
217 struct ipv6_destopt_hao *hao;
218 struct inet6_skb_parm *opt = IP6CB(skb);
219 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
220 struct in6_addr tmp_addr;
224 LIMIT_NETDEBUG(KERN_DEBUG "hao duplicated\n");
227 opt->dsthao = opt->dst1;
230 hao = (struct ipv6_destopt_hao *)(skb_network_header(skb) + optoff);
232 if (hao->length != 16) {
234 KERN_DEBUG "hao invalid option length = %d\n", hao->length);
238 if (!(ipv6_addr_type(&hao->addr) & IPV6_ADDR_UNICAST)) {
240 KERN_DEBUG "hao is not an unicast addr: %pI6\n", &hao->addr);
244 ret = xfrm6_input_addr(skb, (xfrm_address_t *)&ipv6h->daddr,
245 (xfrm_address_t *)&hao->addr, IPPROTO_DSTOPTS);
246 if (unlikely(ret < 0))
249 if (skb_cloned(skb)) {
250 if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
253 /* update all variable using below by copied skbuff */
254 hao = (struct ipv6_destopt_hao *)(skb_network_header(skb) +
256 ipv6h = ipv6_hdr(skb);
259 if (skb->ip_summed == CHECKSUM_COMPLETE)
260 skb->ip_summed = CHECKSUM_NONE;
262 tmp_addr = ipv6h->saddr;
263 ipv6h->saddr = hao->addr;
264 hao->addr = tmp_addr;
266 if (skb->tstamp.tv64 == 0)
267 __net_timestamp(skb);
277 static struct tlvtype_proc tlvprocdestopt_lst[] = {
278 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
280 .type = IPV6_TLV_HAO,
281 .func = ipv6_dest_hao,
287 static int ipv6_destopt_rcv(struct sk_buff *skb)
289 struct inet6_skb_parm *opt = IP6CB(skb);
290 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
293 struct dst_entry *dst = skb_dst(skb);
295 if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
296 !pskb_may_pull(skb, (skb_transport_offset(skb) +
297 ((skb_transport_header(skb)[1] + 1) << 3)))) {
298 IP6_INC_STATS_BH(dev_net(dst->dev), ip6_dst_idev(dst),
299 IPSTATS_MIB_INHDRERRORS);
304 opt->lastopt = opt->dst1 = skb_network_header_len(skb);
305 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
309 if (ip6_parse_tlv(tlvprocdestopt_lst, skb)) {
310 skb->transport_header += (skb_transport_header(skb)[1] + 1) << 3;
312 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
315 opt->nhoff = opt->dst1;
320 IP6_INC_STATS_BH(dev_net(dst->dev),
321 ip6_dst_idev(dst), IPSTATS_MIB_INHDRERRORS);
325 /********************************
327 ********************************/
329 /* called with rcu_read_lock() */
330 static int ipv6_rthdr_rcv(struct sk_buff *skb)
332 struct inet6_skb_parm *opt = IP6CB(skb);
333 struct in6_addr *addr = NULL;
334 struct in6_addr daddr;
335 struct inet6_dev *idev;
337 struct ipv6_rt_hdr *hdr;
338 struct rt0_hdr *rthdr;
339 struct net *net = dev_net(skb->dev);
340 int accept_source_route = net->ipv6.devconf_all->accept_source_route;
342 idev = __in6_dev_get(skb->dev);
343 if (idev && accept_source_route > idev->cnf.accept_source_route)
344 accept_source_route = idev->cnf.accept_source_route;
346 if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) ||
347 !pskb_may_pull(skb, (skb_transport_offset(skb) +
348 ((skb_transport_header(skb)[1] + 1) << 3)))) {
349 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
350 IPSTATS_MIB_INHDRERRORS);
355 hdr = (struct ipv6_rt_hdr *)skb_transport_header(skb);
357 if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) ||
358 skb->pkt_type != PACKET_HOST) {
359 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
360 IPSTATS_MIB_INADDRERRORS);
366 if (hdr->segments_left == 0) {
368 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
369 case IPV6_SRCRT_TYPE_2:
370 /* Silently discard type 2 header unless it was
374 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
375 IPSTATS_MIB_INADDRERRORS);
385 opt->lastopt = opt->srcrt = skb_network_header_len(skb);
386 skb->transport_header += (hdr->hdrlen + 1) << 3;
387 opt->dst0 = opt->dst1;
389 opt->nhoff = (&hdr->nexthdr) - skb_network_header(skb);
394 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
395 case IPV6_SRCRT_TYPE_2:
396 if (accept_source_route < 0)
398 /* Silently discard invalid RTH type 2 */
399 if (hdr->hdrlen != 2 || hdr->segments_left != 1) {
400 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
401 IPSTATS_MIB_INHDRERRORS);
412 * This is the routing header forwarding algorithm from
416 n = hdr->hdrlen >> 1;
418 if (hdr->segments_left > n) {
419 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
420 IPSTATS_MIB_INHDRERRORS);
421 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
422 ((&hdr->segments_left) -
423 skb_network_header(skb)));
427 /* We are about to mangle packet header. Be careful!
428 Do not damage packets queued somewhere.
430 if (skb_cloned(skb)) {
431 /* the copy is a forwarded packet */
432 if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
433 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
434 IPSTATS_MIB_OUTDISCARDS);
438 hdr = (struct ipv6_rt_hdr *)skb_transport_header(skb);
441 if (skb->ip_summed == CHECKSUM_COMPLETE)
442 skb->ip_summed = CHECKSUM_NONE;
444 i = n - --hdr->segments_left;
446 rthdr = (struct rt0_hdr *) hdr;
451 #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
452 case IPV6_SRCRT_TYPE_2:
453 if (xfrm6_input_addr(skb, (xfrm_address_t *)addr,
454 (xfrm_address_t *)&ipv6_hdr(skb)->saddr,
455 IPPROTO_ROUTING) < 0) {
456 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
457 IPSTATS_MIB_INADDRERRORS);
461 if (!ipv6_chk_home_addr(dev_net(skb_dst(skb)->dev), addr)) {
462 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
463 IPSTATS_MIB_INADDRERRORS);
473 if (ipv6_addr_is_multicast(addr)) {
474 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
475 IPSTATS_MIB_INADDRERRORS);
481 *addr = ipv6_hdr(skb)->daddr;
482 ipv6_hdr(skb)->daddr = daddr;
485 ip6_route_input(skb);
486 if (skb_dst(skb)->error) {
487 skb_push(skb, skb->data - skb_network_header(skb));
492 if (skb_dst(skb)->dev->flags&IFF_LOOPBACK) {
493 if (ipv6_hdr(skb)->hop_limit <= 1) {
494 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)),
495 IPSTATS_MIB_INHDRERRORS);
496 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT,
501 ipv6_hdr(skb)->hop_limit--;
505 skb_push(skb, skb->data - skb_network_header(skb));
510 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_INHDRERRORS);
511 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
512 (&hdr->type) - skb_network_header(skb));
516 static const struct inet6_protocol rthdr_protocol = {
517 .handler = ipv6_rthdr_rcv,
518 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
521 static const struct inet6_protocol destopt_protocol = {
522 .handler = ipv6_destopt_rcv,
523 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
526 static const struct inet6_protocol nodata_protocol = {
527 .handler = dst_discard,
528 .flags = INET6_PROTO_NOPOLICY,
531 int __init ipv6_exthdrs_init(void)
535 ret = inet6_add_protocol(&rthdr_protocol, IPPROTO_ROUTING);
539 ret = inet6_add_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
543 ret = inet6_add_protocol(&nodata_protocol, IPPROTO_NONE);
550 inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
552 inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
556 void ipv6_exthdrs_exit(void)
558 inet6_del_protocol(&nodata_protocol, IPPROTO_NONE);
559 inet6_del_protocol(&destopt_protocol, IPPROTO_DSTOPTS);
560 inet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);
563 /**********************************
565 **********************************/
568 * Note: we cannot rely on skb_dst(skb) before we assign it in ip6_route_input().
570 static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb)
572 return skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) : __in6_dev_get(skb->dev);
575 static inline struct net *ipv6_skb_net(struct sk_buff *skb)
577 return skb_dst(skb) ? dev_net(skb_dst(skb)->dev) : dev_net(skb->dev);
580 /* Router Alert as of RFC 2711 */
582 static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
584 const unsigned char *nh = skb_network_header(skb);
586 if (nh[optoff + 1] == 2) {
587 IP6CB(skb)->ra = optoff;
590 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
598 static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
600 const unsigned char *nh = skb_network_header(skb);
601 struct net *net = ipv6_skb_net(skb);
604 if (nh[optoff + 1] != 4 || (optoff & 3) != 2) {
605 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
607 IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
608 IPSTATS_MIB_INHDRERRORS);
612 pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
613 if (pkt_len <= IPV6_MAXPLEN) {
614 IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
615 IPSTATS_MIB_INHDRERRORS);
616 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);
619 if (ipv6_hdr(skb)->payload_len) {
620 IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
621 IPSTATS_MIB_INHDRERRORS);
622 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);
626 if (pkt_len > skb->len - sizeof(struct ipv6hdr)) {
627 IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
628 IPSTATS_MIB_INTRUNCATEDPKTS);
632 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
642 static struct tlvtype_proc tlvprochopopt_lst[] = {
644 .type = IPV6_TLV_ROUTERALERT,
648 .type = IPV6_TLV_JUMBO,
649 .func = ipv6_hop_jumbo,
654 int ipv6_parse_hopopts(struct sk_buff *skb)
656 struct inet6_skb_parm *opt = IP6CB(skb);
659 * skb_network_header(skb) is equal to skb->data, and
660 * skb_network_header_len(skb) is always equal to
661 * sizeof(struct ipv6hdr) by definition of
662 * hop-by-hop options.
664 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr) + 8) ||
665 !pskb_may_pull(skb, (sizeof(struct ipv6hdr) +
666 ((skb_transport_header(skb)[1] + 1) << 3)))) {
671 opt->hop = sizeof(struct ipv6hdr);
672 if (ip6_parse_tlv(tlvprochopopt_lst, skb)) {
673 skb->transport_header += (skb_transport_header(skb)[1] + 1) << 3;
675 opt->nhoff = sizeof(struct ipv6hdr);
682 * Creating outbound headers.
684 * "build" functions work when skb is filled from head to tail (datagram)
685 * "push" functions work when headers are added from tail to head (tcp)
687 * In both cases we assume, that caller reserved enough room
691 static void ipv6_push_rthdr(struct sk_buff *skb, u8 *proto,
692 struct ipv6_rt_hdr *opt,
693 struct in6_addr **addr_p)
695 struct rt0_hdr *phdr, *ihdr;
698 ihdr = (struct rt0_hdr *) opt;
700 phdr = (struct rt0_hdr *) skb_push(skb, (ihdr->rt_hdr.hdrlen + 1) << 3);
701 memcpy(phdr, ihdr, sizeof(struct rt0_hdr));
703 hops = ihdr->rt_hdr.hdrlen >> 1;
706 memcpy(phdr->addr, ihdr->addr + 1,
707 (hops - 1) * sizeof(struct in6_addr));
709 phdr->addr[hops - 1] = **addr_p;
710 *addr_p = ihdr->addr;
712 phdr->rt_hdr.nexthdr = *proto;
713 *proto = NEXTHDR_ROUTING;
716 static void ipv6_push_exthdr(struct sk_buff *skb, u8 *proto, u8 type, struct ipv6_opt_hdr *opt)
718 struct ipv6_opt_hdr *h = (struct ipv6_opt_hdr *)skb_push(skb, ipv6_optlen(opt));
720 memcpy(h, opt, ipv6_optlen(opt));
725 void ipv6_push_nfrag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt,
727 struct in6_addr **daddr)
730 ipv6_push_rthdr(skb, proto, opt->srcrt, daddr);
732 * IPV6_RTHDRDSTOPTS is ignored
733 * unless IPV6_RTHDR is set (RFC3542).
736 ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst0opt);
739 ipv6_push_exthdr(skb, proto, NEXTHDR_HOP, opt->hopopt);
741 EXPORT_SYMBOL(ipv6_push_nfrag_opts);
743 void ipv6_push_frag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt, u8 *proto)
746 ipv6_push_exthdr(skb, proto, NEXTHDR_DEST, opt->dst1opt);
749 struct ipv6_txoptions *
750 ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)
752 struct ipv6_txoptions *opt2;
754 opt2 = sock_kmalloc(sk, opt->tot_len, GFP_ATOMIC);
756 long dif = (char *)opt2 - (char *)opt;
757 memcpy(opt2, opt, opt->tot_len);
759 *((char **)&opt2->hopopt) += dif;
761 *((char **)&opt2->dst0opt) += dif;
763 *((char **)&opt2->dst1opt) += dif;
765 *((char **)&opt2->srcrt) += dif;
769 EXPORT_SYMBOL_GPL(ipv6_dup_options);
771 static int ipv6_renew_option(void *ohdr,
772 struct ipv6_opt_hdr __user *newopt, int newoptlen,
774 struct ipv6_opt_hdr **hdr,
779 memcpy(*p, ohdr, ipv6_optlen((struct ipv6_opt_hdr *)ohdr));
780 *hdr = (struct ipv6_opt_hdr *)*p;
781 *p += CMSG_ALIGN(ipv6_optlen(*(struct ipv6_opt_hdr **)hdr));
785 if (copy_from_user(*p, newopt, newoptlen))
787 *hdr = (struct ipv6_opt_hdr *)*p;
788 if (ipv6_optlen(*(struct ipv6_opt_hdr **)hdr) > newoptlen)
790 *p += CMSG_ALIGN(newoptlen);
796 struct ipv6_txoptions *
797 ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,
799 struct ipv6_opt_hdr __user *newopt, int newoptlen)
803 struct ipv6_txoptions *opt2;
807 if (newtype != IPV6_HOPOPTS && opt->hopopt)
808 tot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt));
809 if (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt)
810 tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt));
811 if (newtype != IPV6_RTHDR && opt->srcrt)
812 tot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt));
813 if (newtype != IPV6_DSTOPTS && opt->dst1opt)
814 tot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));
817 if (newopt && newoptlen)
818 tot_len += CMSG_ALIGN(newoptlen);
823 tot_len += sizeof(*opt2);
824 opt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC);
826 return ERR_PTR(-ENOBUFS);
828 memset(opt2, 0, tot_len);
830 opt2->tot_len = tot_len;
831 p = (char *)(opt2 + 1);
833 err = ipv6_renew_option(opt ? opt->hopopt : NULL, newopt, newoptlen,
834 newtype != IPV6_HOPOPTS,
839 err = ipv6_renew_option(opt ? opt->dst0opt : NULL, newopt, newoptlen,
840 newtype != IPV6_RTHDRDSTOPTS,
845 err = ipv6_renew_option(opt ? opt->srcrt : NULL, newopt, newoptlen,
846 newtype != IPV6_RTHDR,
847 (struct ipv6_opt_hdr **)&opt2->srcrt, &p);
851 err = ipv6_renew_option(opt ? opt->dst1opt : NULL, newopt, newoptlen,
852 newtype != IPV6_DSTOPTS,
857 opt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +
858 (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +
859 (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0);
860 opt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);
864 sock_kfree_s(sk, opt2, opt2->tot_len);
868 struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
869 struct ipv6_txoptions *opt)
872 * ignore the dest before srcrt unless srcrt is being included.
875 if (opt && opt->dst0opt && !opt->srcrt) {
876 if (opt_space != opt) {
877 memcpy(opt_space, opt, sizeof(*opt_space));
880 opt->opt_nflen -= ipv6_optlen(opt->dst0opt);
886 EXPORT_SYMBOL_GPL(ipv6_fixup_options);
889 * fl6_update_dst - update flowi destination address with info given
890 * by srcrt option, if any.
892 * @fl6: flowi6 for which daddr is to be updated
893 * @opt: struct ipv6_txoptions in which to look for srcrt opt
894 * @orig: copy of original daddr address if modified
896 * Returns NULL if no txoptions or no srcrt, otherwise returns orig
897 * and initial value of fl6->daddr set in orig
899 struct in6_addr *fl6_update_dst(struct flowi6 *fl6,
900 const struct ipv6_txoptions *opt,
901 struct in6_addr *orig)
903 if (!opt || !opt->srcrt)
907 fl6->daddr = *((struct rt0_hdr *)opt->srcrt)->addr;
910 EXPORT_SYMBOL_GPL(fl6_update_dst);