diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2004-08-02 03:04:02 -0700 |
---|---|---|
committer | David S. Miller <davem@nuts.davemloft.net> | 2004-08-02 03:04:02 -0700 |
commit | 7ce6d8befd73acdafe6ccfd0a2c7fe3d0db7dc8a (patch) | |
tree | 6809be5904f4673a93b69f6ae5376599f284f1a0 /net | |
parent | d8fd3ac0db6c120373c6842dd9fb7f864dc5bbfb (diff) | |
download | history-7ce6d8befd73acdafe6ccfd0a2c7fe3d0db7dc8a.tar.gz |
[IPSEC]: Move xfrm[46]_tunnel_check_size into xfrm[46]_output.c
This patch moves xfrm[46]_tunnel_check_size() into xfrm[46]_output.c
where it can be made static since it's only used there.
While moving the icmp.h inclusions over I also discovered that the
tunnel files are missing an inclusion of net/protocol.h. So I've
added them as well.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/xfrm4_output.c | 25 | ||||
-rw-r--r-- | net/ipv4/xfrm4_tunnel.c | 26 | ||||
-rw-r--r-- | net/ipv6/xfrm6_output.c | 18 | ||||
-rw-r--r-- | net/ipv6/xfrm6_tunnel.c | 21 | ||||
-rw-r--r-- | net/xfrm/xfrm_export.c | 1 |
5 files changed, 45 insertions, 46 deletions
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c index f65ec865a9a68d..191cec718e95ac 100644 --- a/net/ipv4/xfrm4_output.c +++ b/net/ipv4/xfrm4_output.c @@ -13,6 +13,7 @@ #include <net/inet_ecn.h> #include <net/ip.h> #include <net/xfrm.h> +#include <net/icmp.h> /* Add encapsulation header. * @@ -67,6 +68,30 @@ static void xfrm4_encap(struct sk_buff *skb) memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options)); } +static int xfrm4_tunnel_check_size(struct sk_buff *skb) +{ + int mtu, ret = 0; + struct dst_entry *dst; + struct iphdr *iph = skb->nh.iph; + + if (IPCB(skb)->flags & IPSKB_XFRM_TUNNEL_SIZE) + goto out; + + IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE; + + if (!(iph->frag_off & htons(IP_DF))) + goto out; + + dst = skb->dst; + mtu = dst_pmtu(dst) - dst->header_len - dst->trailer_len; + if (skb->len > mtu) { + icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); + ret = -EMSGSIZE; + } +out: + return ret; +} + int xfrm4_output(struct sk_buff **pskb) { struct sk_buff *skb = *pskb; diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c index 710a281bac710d..0d1a0b0c790126 100644 --- a/net/ipv4/xfrm4_tunnel.c +++ b/net/ipv4/xfrm4_tunnel.c @@ -6,31 +6,7 @@ #include <linux/skbuff.h> #include <net/xfrm.h> #include <net/ip.h> -#include <net/icmp.h> - -int xfrm4_tunnel_check_size(struct sk_buff *skb) -{ - int mtu, ret = 0; - struct dst_entry *dst; - struct iphdr *iph = skb->nh.iph; - - if (IPCB(skb)->flags & IPSKB_XFRM_TUNNEL_SIZE) - goto out; - - IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE; - - if (!(iph->frag_off & htons(IP_DF))) - goto out; - - dst = skb->dst; - mtu = dst_pmtu(dst) - dst->header_len - dst->trailer_len; - if (skb->len > mtu) { - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); - ret = -EMSGSIZE; - } -out: - return ret; -} +#include <net/protocol.h> static int ipip_output(struct sk_buff **pskb) { diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 028c9dd96bebe5..712856f0f35699 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c @@ -11,6 +11,7 @@ #include <linux/skbuff.h> #include <linux/spinlock.h> +#include <linux/icmpv6.h> #include <net/inet_ecn.h> #include <net/ipv6.h> #include <net/xfrm.h> @@ -68,6 +69,23 @@ static void xfrm6_encap(struct sk_buff *skb) ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); } +static int xfrm6_tunnel_check_size(struct sk_buff *skb) +{ + int mtu, ret = 0; + struct dst_entry *dst = skb->dst; + + mtu = dst_pmtu(dst) - sizeof(struct ipv6hdr); + if (mtu < IPV6_MIN_MTU) + mtu = IPV6_MIN_MTU; + + if (skb->len > mtu) { + icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev); + ret = -EMSGSIZE; + } + + return ret; +} + int xfrm6_output(struct sk_buff **pskb) { struct sk_buff *skb = *pskb; diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c index d35c87ff83ddff..5766a133411a35 100644 --- a/net/ipv6/xfrm6_tunnel.c +++ b/net/ipv6/xfrm6_tunnel.c @@ -27,8 +27,8 @@ #include <linux/list.h> #include <net/ip.h> #include <net/xfrm.h> -#include <net/icmp.h> #include <net/ipv6.h> +#include <net/protocol.h> #include <linux/ipv6.h> #include <linux/icmpv6.h> @@ -343,25 +343,6 @@ void xfrm6_tunnel_free_spi(xfrm_address_t *saddr) EXPORT_SYMBOL(xfrm6_tunnel_free_spi); -int xfrm6_tunnel_check_size(struct sk_buff *skb) -{ - int mtu, ret = 0; - struct dst_entry *dst = skb->dst; - - mtu = dst_pmtu(dst) - sizeof(struct ipv6hdr); - if (mtu < IPV6_MIN_MTU) - mtu = IPV6_MIN_MTU; - - if (skb->len > mtu) { - icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev); - ret = -EMSGSIZE; - } - - return ret; -} - -EXPORT_SYMBOL(xfrm6_tunnel_check_size); - static int xfrm6_tunnel_output(struct sk_buff **pskb) { struct sk_buff *skb = *pskb; diff --git a/net/xfrm/xfrm_export.c b/net/xfrm/xfrm_export.c index e77179ccf742d1..f72754953d2976 100644 --- a/net/xfrm/xfrm_export.c +++ b/net/xfrm/xfrm_export.c @@ -35,7 +35,6 @@ EXPORT_SYMBOL(xfrm_parse_spi); EXPORT_SYMBOL(xfrm4_rcv); EXPORT_SYMBOL(xfrm4_tunnel_register); EXPORT_SYMBOL(xfrm4_tunnel_deregister); -EXPORT_SYMBOL(xfrm4_tunnel_check_size); EXPORT_SYMBOL(xfrm_register_type); EXPORT_SYMBOL(xfrm_unregister_type); EXPORT_SYMBOL(xfrm_get_type); |