[IPVS]: Replace local version of skb_make_writable
This patch removes the IPVS-specific version of skb_make_writable and replaces it with the netfilter one. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
37d4187922
commit
af1e1cf073
@ -984,7 +984,6 @@ static inline char ip_vs_fwd_tag(struct ip_vs_conn *cp)
|
|||||||
return fwd;
|
return fwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ip_vs_make_skb_writable(struct sk_buff **pskb, int len);
|
|
||||||
extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
|
extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
|
||||||
struct ip_vs_conn *cp, int dir);
|
struct ip_vs_conn *cp, int dir);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/in.h>
|
#include <linux/in.h>
|
||||||
#include <linux/ip.h>
|
#include <linux/ip.h>
|
||||||
|
#include <linux/netfilter.h>
|
||||||
#include <net/net_namespace.h>
|
#include <net/net_namespace.h>
|
||||||
#include <net/protocol.h>
|
#include <net/protocol.h>
|
||||||
#include <net/tcp.h>
|
#include <net/tcp.h>
|
||||||
@ -336,7 +337,7 @@ static inline int app_tcp_pkt_out(struct ip_vs_conn *cp, struct sk_buff **pskb,
|
|||||||
struct tcphdr *th;
|
struct tcphdr *th;
|
||||||
__u32 seq;
|
__u32 seq;
|
||||||
|
|
||||||
if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th)))
|
if (!skb_make_writable(*pskb, tcp_offset + sizeof(*th)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset);
|
th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset);
|
||||||
@ -411,7 +412,7 @@ static inline int app_tcp_pkt_in(struct ip_vs_conn *cp, struct sk_buff **pskb,
|
|||||||
struct tcphdr *th;
|
struct tcphdr *th;
|
||||||
__u32 seq;
|
__u32 seq;
|
||||||
|
|
||||||
if (!ip_vs_make_skb_writable(pskb, tcp_offset + sizeof(*th)))
|
if (!skb_make_writable(*pskb, tcp_offset + sizeof(*th)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset);
|
th = (struct tcphdr *)(skb_network_header(*pskb) + tcp_offset);
|
||||||
|
@ -58,7 +58,6 @@ EXPORT_SYMBOL(ip_vs_conn_put);
|
|||||||
#ifdef CONFIG_IP_VS_DEBUG
|
#ifdef CONFIG_IP_VS_DEBUG
|
||||||
EXPORT_SYMBOL(ip_vs_get_debug_level);
|
EXPORT_SYMBOL(ip_vs_get_debug_level);
|
||||||
#endif
|
#endif
|
||||||
EXPORT_SYMBOL(ip_vs_make_skb_writable);
|
|
||||||
|
|
||||||
|
|
||||||
/* ID used in ICMP lookups */
|
/* ID used in ICMP lookups */
|
||||||
@ -163,42 +162,6 @@ ip_vs_set_state(struct ip_vs_conn *cp, int direction,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ip_vs_make_skb_writable(struct sk_buff **pskb, int writable_len)
|
|
||||||
{
|
|
||||||
struct sk_buff *skb = *pskb;
|
|
||||||
|
|
||||||
/* skb is already used, better copy skb and its payload */
|
|
||||||
if (unlikely(skb_shared(skb) || skb->sk))
|
|
||||||
goto copy_skb;
|
|
||||||
|
|
||||||
/* skb data is already used, copy it */
|
|
||||||
if (unlikely(skb_cloned(skb)))
|
|
||||||
goto copy_data;
|
|
||||||
|
|
||||||
return pskb_may_pull(skb, writable_len);
|
|
||||||
|
|
||||||
copy_data:
|
|
||||||
if (unlikely(writable_len > skb->len))
|
|
||||||
return 0;
|
|
||||||
return !pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
|
|
||||||
|
|
||||||
copy_skb:
|
|
||||||
if (unlikely(writable_len > skb->len))
|
|
||||||
return 0;
|
|
||||||
skb = skb_copy(skb, GFP_ATOMIC);
|
|
||||||
if (!skb)
|
|
||||||
return 0;
|
|
||||||
BUG_ON(skb_is_nonlinear(skb));
|
|
||||||
|
|
||||||
/* Rest of kernel will get very unhappy if we pass it a
|
|
||||||
suddenly-orphaned skbuff */
|
|
||||||
if ((*pskb)->sk)
|
|
||||||
skb_set_owner_w(skb, (*pskb)->sk);
|
|
||||||
kfree_skb(*pskb);
|
|
||||||
*pskb = skb;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IPVS persistent scheduling function
|
* IPVS persistent scheduling function
|
||||||
* It creates a connection entry according to its template if exists,
|
* It creates a connection entry according to its template if exists,
|
||||||
@ -689,9 +652,8 @@ static int ip_vs_out_icmp(struct sk_buff **pskb, int *related)
|
|||||||
|
|
||||||
if (IPPROTO_TCP == cih->protocol || IPPROTO_UDP == cih->protocol)
|
if (IPPROTO_TCP == cih->protocol || IPPROTO_UDP == cih->protocol)
|
||||||
offset += 2 * sizeof(__u16);
|
offset += 2 * sizeof(__u16);
|
||||||
if (!ip_vs_make_skb_writable(pskb, offset))
|
if (!skb_make_writable(skb, offset))
|
||||||
goto out;
|
goto out;
|
||||||
skb = *pskb;
|
|
||||||
|
|
||||||
ip_vs_nat_icmp(skb, pp, cp, 1);
|
ip_vs_nat_icmp(skb, pp, cp, 1);
|
||||||
|
|
||||||
@ -799,7 +761,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
|
|||||||
|
|
||||||
IP_VS_DBG_PKT(11, pp, skb, 0, "Outgoing packet");
|
IP_VS_DBG_PKT(11, pp, skb, 0, "Outgoing packet");
|
||||||
|
|
||||||
if (!ip_vs_make_skb_writable(pskb, ihl))
|
if (!skb_make_writable(skb, ihl))
|
||||||
goto drop;
|
goto drop;
|
||||||
|
|
||||||
/* mangle the packet */
|
/* mangle the packet */
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
#include <linux/in.h>
|
#include <linux/in.h>
|
||||||
#include <linux/ip.h>
|
#include <linux/ip.h>
|
||||||
|
#include <linux/netfilter.h>
|
||||||
#include <net/protocol.h>
|
#include <net/protocol.h>
|
||||||
#include <net/tcp.h>
|
#include <net/tcp.h>
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
@ -155,7 +156,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Linear packets are much easier to deal with. */
|
/* Linear packets are much easier to deal with. */
|
||||||
if (!ip_vs_make_skb_writable(pskb, (*pskb)->len))
|
if (!skb_make_writable(*pskb, (*pskb)->len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (cp->app_data == &ip_vs_ftp_pasv) {
|
if (cp->app_data == &ip_vs_ftp_pasv) {
|
||||||
@ -256,7 +257,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* Linear packets are much easier to deal with. */
|
/* Linear packets are much easier to deal with. */
|
||||||
if (!ip_vs_make_skb_writable(pskb, (*pskb)->len))
|
if (!skb_make_writable(*pskb, (*pskb)->len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <linux/tcp.h> /* for tcphdr */
|
#include <linux/tcp.h> /* for tcphdr */
|
||||||
#include <net/ip.h>
|
#include <net/ip.h>
|
||||||
#include <net/tcp.h> /* for csum_tcpudp_magic */
|
#include <net/tcp.h> /* for csum_tcpudp_magic */
|
||||||
|
#include <linux/netfilter.h>
|
||||||
#include <linux/netfilter_ipv4.h>
|
#include <linux/netfilter_ipv4.h>
|
||||||
|
|
||||||
#include <net/ip_vs.h>
|
#include <net/ip_vs.h>
|
||||||
@ -129,7 +130,7 @@ tcp_snat_handler(struct sk_buff **pskb,
|
|||||||
const unsigned int tcphoff = ip_hdrlen(*pskb);
|
const unsigned int tcphoff = ip_hdrlen(*pskb);
|
||||||
|
|
||||||
/* csum_check requires unshared skb */
|
/* csum_check requires unshared skb */
|
||||||
if (!ip_vs_make_skb_writable(pskb, tcphoff+sizeof(*tcph)))
|
if (!skb_make_writable(*pskb, tcphoff+sizeof(*tcph)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (unlikely(cp->app != NULL)) {
|
if (unlikely(cp->app != NULL)) {
|
||||||
@ -177,7 +178,7 @@ tcp_dnat_handler(struct sk_buff **pskb,
|
|||||||
const unsigned int tcphoff = ip_hdrlen(*pskb);
|
const unsigned int tcphoff = ip_hdrlen(*pskb);
|
||||||
|
|
||||||
/* csum_check requires unshared skb */
|
/* csum_check requires unshared skb */
|
||||||
if (!ip_vs_make_skb_writable(pskb, tcphoff+sizeof(*tcph)))
|
if (!skb_make_writable(*pskb, tcphoff+sizeof(*tcph)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (unlikely(cp->app != NULL)) {
|
if (unlikely(cp->app != NULL)) {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <linux/in.h>
|
#include <linux/in.h>
|
||||||
#include <linux/ip.h>
|
#include <linux/ip.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/netfilter.h>
|
||||||
#include <linux/netfilter_ipv4.h>
|
#include <linux/netfilter_ipv4.h>
|
||||||
#include <linux/udp.h>
|
#include <linux/udp.h>
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ udp_snat_handler(struct sk_buff **pskb,
|
|||||||
const unsigned int udphoff = ip_hdrlen(*pskb);
|
const unsigned int udphoff = ip_hdrlen(*pskb);
|
||||||
|
|
||||||
/* csum_check requires unshared skb */
|
/* csum_check requires unshared skb */
|
||||||
if (!ip_vs_make_skb_writable(pskb, udphoff+sizeof(*udph)))
|
if (!skb_make_writable(*pskb, udphoff+sizeof(*udph)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (unlikely(cp->app != NULL)) {
|
if (unlikely(cp->app != NULL)) {
|
||||||
@ -190,7 +191,7 @@ udp_dnat_handler(struct sk_buff **pskb,
|
|||||||
unsigned int udphoff = ip_hdrlen(*pskb);
|
unsigned int udphoff = ip_hdrlen(*pskb);
|
||||||
|
|
||||||
/* csum_check requires unshared skb */
|
/* csum_check requires unshared skb */
|
||||||
if (!ip_vs_make_skb_writable(pskb, udphoff+sizeof(*udph)))
|
if (!skb_make_writable(*pskb, udphoff+sizeof(*udph)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (unlikely(cp->app != NULL)) {
|
if (unlikely(cp->app != NULL)) {
|
||||||
|
@ -253,7 +253,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy-on-write the packet before mangling it */
|
/* copy-on-write the packet before mangling it */
|
||||||
if (!ip_vs_make_skb_writable(&skb, sizeof(struct iphdr)))
|
if (!skb_make_writable(skb, sizeof(struct iphdr)))
|
||||||
goto tx_error_put;
|
goto tx_error_put;
|
||||||
|
|
||||||
if (skb_cow(skb, rt->u.dst.dev->hard_header_len))
|
if (skb_cow(skb, rt->u.dst.dev->hard_header_len))
|
||||||
@ -529,7 +529,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy-on-write the packet before mangling it */
|
/* copy-on-write the packet before mangling it */
|
||||||
if (!ip_vs_make_skb_writable(&skb, offset))
|
if (!skb_make_writable(skb, offset))
|
||||||
goto tx_error_put;
|
goto tx_error_put;
|
||||||
|
|
||||||
if (skb_cow(skb, rt->u.dst.dev->hard_header_len))
|
if (skb_cow(skb, rt->u.dst.dev->hard_header_len))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user