--- zzzz-none-000/linux-4.4.60/include/linux/skbuff.h 2017-04-08 07:53:53.000000000 +0000 +++ dragonfly-4020-701/linux-4.4.60/include/linux/skbuff.h 2018-11-08 13:36:17.000000000 +0000 @@ -39,6 +39,13 @@ #include #include +#ifdef CONFIG_AVM_PA +#include +#endif +#ifdef CONFIG_AVM_GENERIC_CONNTRACK +#include +#endif + /* A. Checksumming of received packets by device. * * CHECKSUM_NONE: @@ -559,6 +566,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 +583,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 +659,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 +716,17 @@ __u16 network_header; __u16 mac_header; +#ifdef CONFIG_AVM_PA + union { + struct avm_pa_pkt_info pktinfo; + __u8 buf[256]; + } avm_pa; +#define AVM_PKT_INFO(skb) (&(skb)->avm_pa.pktinfo) +#endif +#ifdef CONFIG_AVM_GENERIC_CONNTRACK + struct generic_ct *generic_ct; +#endif + /* private: */ __u32 headers_end[0]; /* public: */ @@ -708,9 +738,25 @@ *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__ + +#ifdef CONFIG_AVM_PA +static inline void avm_pa_add_local_session(PKT *pkt, struct sock *sk) +{ + struct avm_pa_pkt_info *info = AVM_PKT_INFO(pkt); + if (info->ptype_pid_handle && info->is_accelerated == 0) + _avm_pa_add_local_session(pkt, sk); +} +#endif /* CONFIG_AVM_PA */ + /* * Handling routines are only of interest to the kernel */ @@ -800,6 +846,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, @@ -2180,7 +2228,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 +2258,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 +2277,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 +2384,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 +3419,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 +3475,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 +3487,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 +3503,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 +3522,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 +3540,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