]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/ipv6/exthdrs.c
ipv6: Refactor update of IPv6 flowi destination address for srcrt (RH) option
[mirror_ubuntu-artful-kernel.git] / net / ipv6 / exthdrs.c
index 8a659f92d17af2a271f1c4a0ba6e72af6f6bbea1..853a633a94d4f4fe55ec1815fadfd27dd7a9fd03 100644 (file)
@@ -874,3 +874,27 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
        return opt;
 }
 
+/**
+ * fl6_update_dst - update flowi destination address with info given
+ *                  by srcrt option, if any.
+ *
+ * @fl: flowi for which fl6_dst is to be updated
+ * @opt: struct ipv6_txoptions in which to look for srcrt opt
+ * @orig: copy of original fl6_dst address if modified
+ *
+ * Returns NULL if no txoptions or no srcrt, otherwise returns orig
+ * and initial value of fl->fl6_dst set in orig
+ */
+struct in6_addr *fl6_update_dst(struct flowi *fl,
+                               const struct ipv6_txoptions *opt,
+                               struct in6_addr *orig)
+{
+       if (!opt || !opt->srcrt)
+               return NULL;
+
+       ipv6_addr_copy(orig, &fl->fl6_dst);
+       ipv6_addr_copy(&fl->fl6_dst, ((struct rt0_hdr *)opt->srcrt)->addr);
+       return orig;
+}
+
+EXPORT_SYMBOL_GPL(fl6_update_dst);