--- zzzz-none-000/linux-4.4.60/include/linux/skbuff.h 2017-04-08 07:53:53.000000000 +0000 +++ scorpion-7490-727/linux-4.4.60/include/linux/skbuff.h 2021-02-04 17:41:59.000000000 +0000 @@ -39,6 +39,17 @@ #include #include +#ifdef CONFIG_AVM_PA +/* Cannot include avm_pa.h */ +struct avm_pa_pkt_info; +/* transitional define to allow older avm_pa tags, to be removed */ +#define SKBUFF_H_NO_AVM_PA_H 1 +#endif + +#ifdef CONFIG_AVM_GENERIC_CONNTRACK +#include +#endif + /* A. Checksumming of received packets by device. * * CHECKSUM_NONE: @@ -559,6 +570,9 @@ }; struct sock *sk; struct net_device *dev; +#if IS_ENABLED(CONFIG_AVM_NET_SKB_INPUT_DEV) + struct net_device *input_dev; +#endif /* * This is the control buffer. It is free to use for every @@ -573,6 +587,13 @@ #ifdef CONFIG_XFRM struct sec_path *sp; #endif +#ifdef CONFIG_AVM_ENHANCED + /* uniq_id: Attention! This field does not exist in the 2.6.32 kernel + * anymore. We just use it to pass port and queue information between + * avm_cpmac and multid/dsld in the upper eight bits. */ + unsigned long uniq_id; +#define AVM_HAVE_SKB_UNIQ_ID +#endif #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) struct nf_conntrack *nfct; #endif @@ -642,7 +663,9 @@ __u8 ipvs_property:1; __u8 inner_protocol_type:1; __u8 remcsum_offload:1; - /* 3 or 5 bit hole */ + __u8 gro_skip:1; + __u8 fast_forwarded:1; + /* 1 or 3 bit hole */ #ifdef CONFIG_NET_SCHED __u16 tc_index; /* traffic control index */ @@ -697,6 +720,14 @@ __u16 network_header; __u16 mac_header; +#ifdef CONFIG_AVM_PA + __u8 avm_pa[256]; +#define AVM_PKT_INFO(skb) ((struct avm_pa_pkt_info *) (skb)->avm_pa) +#endif +#ifdef CONFIG_AVM_GENERIC_CONNTRACK + struct generic_ct *generic_ct; +#endif + /* private: */ __u32 headers_end[0]; /* public: */ @@ -708,6 +739,12 @@ *data; unsigned int truesize; atomic_t users; +#ifdef CONFIG_DEBUG_OBJECTS_SKBUFF +#define DEBUG_OBJECTS_SKBUFF_STACKSIZE 20 + void *free_addr[DEBUG_OBJECTS_SKBUFF_STACKSIZE]; + void *alloc_addr[DEBUG_OBJECTS_SKBUFF_STACKSIZE]; + u32 sum; +#endif }; #ifdef __KERNEL__ @@ -800,6 +837,8 @@ void consume_skb(struct sk_buff *skb); void __kfree_skb(struct sk_buff *skb); extern struct kmem_cache *skbuff_head_cache; +extern void kfree_skbmem(struct sk_buff *skb); +extern void skb_release_data(struct sk_buff *skb); void kfree_skb_partial(struct sk_buff *skb, bool head_stolen); bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, @@ -1812,6 +1851,52 @@ return tmp; } +static inline void *__skb_put_zero(struct sk_buff *skb, unsigned int len) +{ + void *tmp = __skb_put(skb, len); + + memset(tmp, 0, len); + return tmp; +} + +static inline void *__skb_put_data(struct sk_buff *skb, const void *data, + unsigned int len) +{ + void *tmp = __skb_put(skb, len); + + memcpy(tmp, data, len); + return tmp; +} + +static inline void __skb_put_u8(struct sk_buff *skb, u8 val) +{ + *(u8 *)__skb_put(skb, 1) = val; +} + +static inline void *skb_put_zero(struct sk_buff *skb, unsigned int len) +{ + void *tmp = skb_put(skb, len); + + memset(tmp, 0, len); + + return tmp; +} + +static inline void *skb_put_data(struct sk_buff *skb, const void *data, + unsigned int len) +{ + void *tmp = skb_put(skb, len); + + memcpy(tmp, data, len); + + return tmp; +} + +static inline void skb_put_u8(struct sk_buff *skb, u8 val) +{ + *(u8 *)skb_put(skb, 1) = val; +} + unsigned char *skb_push(struct sk_buff *skb, unsigned int len); static inline unsigned char *__skb_push(struct sk_buff *skb, unsigned int len) { @@ -2180,7 +2265,7 @@ * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) */ #ifndef NET_SKB_PAD -#define NET_SKB_PAD max(32, L1_CACHE_BYTES) +#define NET_SKB_PAD max(64, L1_CACHE_BYTES) #endif int ___pskb_trim(struct sk_buff *skb, unsigned int len); @@ -2210,6 +2295,10 @@ return (len < skb->len) ? __pskb_trim(skb, len) : 0; } +extern struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length, gfp_t gfp); + + /** * pskb_trim_unique - remove end from a paged unique (not cloned) buffer * @skb: buffer to alter @@ -2225,6 +2314,24 @@ BUG_ON(err); } +/* + * Caller wants to reduce memory needs before queueing skb + * The (expensive) copy should not be be done in fast path. + */ +static inline struct sk_buff *skb_reduce_truesize(struct sk_buff *skb) +{ + if (skb->truesize > 2 * SKB_TRUESIZE(skb->len)) { + struct sk_buff *nskb; + nskb = skb_copy_expand(skb, skb_headroom(skb), 0, + GFP_ATOMIC | __GFP_NOWARN); + if (nskb) { + __kfree_skb(skb); + skb = nskb; + } + } + return skb; +} + /** * skb_orphan - orphan a buffer * @skb: buffer to orphan @@ -2314,16 +2421,6 @@ } -static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, - unsigned int length, gfp_t gfp) -{ - struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); - - if (NET_IP_ALIGN && skb) - skb_reserve(skb, NET_IP_ALIGN); - return skb; -} - static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length) { @@ -3359,6 +3456,37 @@ skb->csum = csum_add(skb->csum, delta); } +#ifdef CONFIG_AVM_GENERIC_CONNTRACK +static inline enum generic_ct_dir skb_get_ct_dir(struct sk_buff *skb) +{ + return skb->nfctinfo ? GENERIC_CT_DIR_REPLY : GENERIC_CT_DIR_ORIGINAL; +} + +static inline void skb_set_ct_dir(struct sk_buff *skb, enum generic_ct_dir dir) +{ + skb->nfctinfo = (dir & 1); +} + +static inline void generic_ct_reset(struct sk_buff *skb __maybe_unused) +{ + generic_ct_put(skb->generic_ct); + skb->generic_ct = NULL; +} + +static inline void __generic_ct_copy(struct sk_buff *dst __maybe_unused, + const struct sk_buff *src __maybe_unused) +{ + dst->generic_ct = generic_ct_get(src->generic_ct); + dst->nfctinfo = src->nfctinfo; +} + +static inline void generic_ct_copy(struct sk_buff *dst, const struct sk_buff *src) +{ + generic_ct_put(dst->generic_ct); + __generic_ct_copy(dst, src); +} +#endif + #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) void nf_conntrack_destroy(struct nf_conntrack *nfct); static inline void nf_conntrack_put(struct nf_conntrack *nfct) @@ -3384,7 +3512,7 @@ atomic_inc(&nf_bridge->use); } #endif /* CONFIG_BRIDGE_NETFILTER */ -static inline void nf_reset(struct sk_buff *skb) +static inline void nf_reset_no_generic_ct(struct sk_buff *skb __maybe_unused) { #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) nf_conntrack_put(skb->nfct); @@ -3396,6 +3524,14 @@ #endif } +static inline void nf_reset(struct sk_buff *skb) +{ + nf_reset_no_generic_ct(skb); +#ifdef CONFIG_AVM_GENERIC_CONNTRACK + generic_ct_reset(skb); +#endif +} + static inline void nf_reset_trace(struct sk_buff *skb) { #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) || defined(CONFIG_NF_TABLES) @@ -3404,7 +3540,7 @@ } /* Note: This doesn't put any conntrack and bridge info in dst. */ -static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src, +static inline void __nf_copy_no_generic_ct(struct sk_buff *dst, const struct sk_buff *src, bool copy) { #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) @@ -3423,7 +3559,17 @@ #endif } -static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) +/* Note: This doesn't put any conntrack and bridge info in dst. */ +static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src, + bool copy) +{ + __nf_copy_no_generic_ct(dst, src, copy); +#ifdef CONFIG_AVM_GENERIC_CONNTRACK + __generic_ct_copy(dst, src); +#endif +} + +static inline void nf_copy_no_generic_ct(struct sk_buff *dst, const struct sk_buff *src) { #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) nf_conntrack_put(dst->nfct); @@ -3431,7 +3577,15 @@ #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) nf_bridge_put(dst->nf_bridge); #endif - __nf_copy(dst, src, true); + __nf_copy_no_generic_ct(dst, src, true); +} + +static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) +{ + nf_copy_no_generic_ct(dst, src); +#ifdef CONFIG_AVM_GENERIC_CONNTRACK + generic_ct_copy(dst, src); +#endif } #ifdef CONFIG_NETWORK_SECMARK