diff options
author | Tom Herbert <tom@herbertland.com> | 2016-05-18 12:06:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-20 18:03:16 -0400 |
commit | dc969b81ebb37d6ec3d7659763bf017ee03f3ac1 (patch) | |
tree | fe074147289140551acc56f018bbac679b84779f | |
parent | 440924bbc0e11fb429ccc25f6d9597d5a7a02296 (diff) |
fou: Split out {fou,gue}_build_header
Create __fou_build_header and __gue_build_header. These implement the
protocol generic parts of building the fou and gue header.
fou_build_header and gue_build_header implement the IPv4 specific
functions and call the __*_build_header functions.
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/fou.h | 8 | ||||
-rw-r--r-- | net/ipv4/fou.c | 47 |
2 files changed, 41 insertions, 14 deletions
diff --git a/include/net/fou.h b/include/net/fou.h index 19b8a0c62a98..7d2fda2a3a9c 100644 --- a/include/net/fou.h +++ b/include/net/fou.h | |||
@@ -11,9 +11,9 @@ | |||
11 | size_t fou_encap_hlen(struct ip_tunnel_encap *e); | 11 | size_t fou_encap_hlen(struct ip_tunnel_encap *e); |
12 | static size_t gue_encap_hlen(struct ip_tunnel_encap *e); | 12 | static size_t gue_encap_hlen(struct ip_tunnel_encap *e); |
13 | 13 | ||
14 | int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | 14 | int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, |
15 | u8 *protocol, struct flowi4 *fl4); | 15 | u8 *protocol, __be16 *sport, int type); |
16 | int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | 16 | int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, |
17 | u8 *protocol, struct flowi4 *fl4); | 17 | u8 *protocol, __be16 *sport, int type); |
18 | 18 | ||
19 | #endif | 19 | #endif |
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c index 6cbc72535426..f4f2ddd8f216 100644 --- a/net/ipv4/fou.c +++ b/net/ipv4/fou.c | |||
@@ -780,6 +780,22 @@ static void fou_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e, | |||
780 | *protocol = IPPROTO_UDP; | 780 | *protocol = IPPROTO_UDP; |
781 | } | 781 | } |
782 | 782 | ||
783 | int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | ||
784 | u8 *protocol, __be16 *sport, int type) | ||
785 | { | ||
786 | int err; | ||
787 | |||
788 | err = iptunnel_handle_offloads(skb, type); | ||
789 | if (err) | ||
790 | return err; | ||
791 | |||
792 | *sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), | ||
793 | skb, 0, 0, false); | ||
794 | |||
795 | return 0; | ||
796 | } | ||
797 | EXPORT_SYMBOL(__fou_build_header); | ||
798 | |||
783 | int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | 799 | int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, |
784 | u8 *protocol, struct flowi4 *fl4) | 800 | u8 *protocol, struct flowi4 *fl4) |
785 | { | 801 | { |
@@ -788,26 +804,21 @@ int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | |||
788 | __be16 sport; | 804 | __be16 sport; |
789 | int err; | 805 | int err; |
790 | 806 | ||
791 | err = iptunnel_handle_offloads(skb, type); | 807 | err = __fou_build_header(skb, e, protocol, &sport, type); |
792 | if (err) | 808 | if (err) |
793 | return err; | 809 | return err; |
794 | 810 | ||
795 | sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), | ||
796 | skb, 0, 0, false); | ||
797 | fou_build_udp(skb, e, fl4, protocol, sport); | 811 | fou_build_udp(skb, e, fl4, protocol, sport); |
798 | 812 | ||
799 | return 0; | 813 | return 0; |
800 | } | 814 | } |
801 | EXPORT_SYMBOL(fou_build_header); | 815 | EXPORT_SYMBOL(fou_build_header); |
802 | 816 | ||
803 | int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | 817 | int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, |
804 | u8 *protocol, struct flowi4 *fl4) | 818 | u8 *protocol, __be16 *sport, int type) |
805 | { | 819 | { |
806 | int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM : | ||
807 | SKB_GSO_UDP_TUNNEL; | ||
808 | struct guehdr *guehdr; | 820 | struct guehdr *guehdr; |
809 | size_t hdrlen, optlen = 0; | 821 | size_t hdrlen, optlen = 0; |
810 | __be16 sport; | ||
811 | void *data; | 822 | void *data; |
812 | bool need_priv = false; | 823 | bool need_priv = false; |
813 | int err; | 824 | int err; |
@@ -826,8 +837,8 @@ int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | |||
826 | return err; | 837 | return err; |
827 | 838 | ||
828 | /* Get source port (based on flow hash) before skb_push */ | 839 | /* Get source port (based on flow hash) before skb_push */ |
829 | sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), | 840 | *sport = e->sport ? : udp_flow_src_port(dev_net(skb->dev), |
830 | skb, 0, 0, false); | 841 | skb, 0, 0, false); |
831 | 842 | ||
832 | hdrlen = sizeof(struct guehdr) + optlen; | 843 | hdrlen = sizeof(struct guehdr) + optlen; |
833 | 844 | ||
@@ -872,6 +883,22 @@ int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | |||
872 | 883 | ||
873 | } | 884 | } |
874 | 885 | ||
886 | return 0; | ||
887 | } | ||
888 | EXPORT_SYMBOL(__gue_build_header); | ||
889 | |||
890 | int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | ||
891 | u8 *protocol, struct flowi4 *fl4) | ||
892 | { | ||
893 | int type = e->flags & TUNNEL_ENCAP_FLAG_CSUM ? SKB_GSO_UDP_TUNNEL_CSUM : | ||
894 | SKB_GSO_UDP_TUNNEL; | ||
895 | __be16 sport; | ||
896 | int err; | ||
897 | |||
898 | err = __gue_build_header(skb, e, protocol, &sport, type); | ||
899 | if (err) | ||
900 | return err; | ||
901 | |||
875 | fou_build_udp(skb, e, fl4, protocol, sport); | 902 | fou_build_udp(skb, e, fl4, protocol, sport); |
876 | 903 | ||
877 | return 0; | 904 | return 0; |