pull request (net-next): ipsec-next 2021-06-28
Subsystems (4)
Steffen Klassert
maintainer1) Remove an unneeded error assignment in esp4_gro_receive(). From Yang Li.
2) Add a new byseq state hashtable to find acquire states faster. From Sabrina Dubroca.
3) Remove some unnecessary variables in pfkey_create(). From zuoqilin.
4) Remove the unused description from xfrm_type struct. From Florian Westphal.
5) Fix a spelling mistake in the comment of xfrm_state_ok(). From gushengxian.
6) Replace hdr_off indirections by a small helper function. From Florian Westphal.
7) Remove xfrm4_output_finish and xfrm6_output_finish declarations, they are not used anymore.From Antony Antony.
8) Remove xfrm replay indirections.
From Florian Westphal.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit ea89c862f01e02ec459932c7c3113fa37aedd09a:
net: mana: Use struct_size() in kzalloc() (2021-05-13 15:58:46 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git master
for you to fetch changes up to b5a1d1fe0cbb9d20ba661134a09561af1dc9ebf5:
xfrm: replay: remove last replay indirection (2021-06-21 09:55:06 +0200)
----------------------------------------------------------------
Antony Antony (1):
xfrm: delete xfrm4_output_finish xfrm6_output_finish declarations
Florian Westphal (12):
xfrm: remove description from xfrm_type struct
xfrm: ipv6: add xfrm6_hdr_offset helper
xfrm: ipv6: move mip6_destopt_offset into xfrm core
xfrm: ipv6: move mip6_rthdr_offset into xfrm core
xfrm: remove hdr_offset indirection
xfrm: merge dstopt and routing hdroff functions
xfrm: avoid compiler warning when ipv6 is disabled
xfrm: replay: avoid xfrm replay notify indirection
xfrm: replay: remove advance indirection
xfrm: replay: remove recheck indirection
xfrm: replay: avoid replay indirection
xfrm: replay: remove last replay indirection
Sabrina Dubroca (1):
xfrm: add state hashtable keyed by seq
Yang Li (1):
esp: drop unneeded assignment in esp4_gro_receive()
gushengxian (1):
xfrm: policy: fix a spelling mistake
zuoqilin (1):
net: Remove unnecessary variables
include/net/netns/xfrm.h | 1 + include/net/xfrm.h | 37 +++++----- net/ipv4/ah4.c | 1 - net/ipv4/esp4.c | 1 - net/ipv4/esp4_offload.c | 4 +- net/ipv4/ipcomp.c | 1 - net/ipv4/xfrm4_tunnel.c | 1 - net/ipv6/ah6.c | 2 - net/ipv6/esp6.c | 2 - net/ipv6/esp6_offload.c | 1 - net/ipv6/ipcomp6.c | 2 - net/ipv6/mip6.c | 99 --------------------------- net/ipv6/xfrm6_output.c | 7 -- net/ipv6/xfrm6_tunnel.c | 1 - net/key/af_key.c | 6 +- net/xfrm/xfrm_hash.h | 7 ++ net/xfrm/xfrm_input.c | 6 +- net/xfrm/xfrm_output.c | 83 ++++++++++++++++++++++- net/xfrm/xfrm_policy.c | 2 +- net/xfrm/xfrm_replay.c | 171 ++++++++++++++++++++++++++++------------------- net/xfrm/xfrm_state.c | 67 +++++++++++++++---- 21 files changed, 266 insertions(+), 236 deletions(-)
Steffen Klassert
maintainerPATCH 1/17 esp: drop unneeded assignment in esp4_gro_receive()
From: Yang Li <[email protected]>
Making '!=' operation with 0 directly after calling the function xfrm_parse_spi() is more efficient, assignment to err is redundant.
Eliminate the following clang_analyzer warning:net/ipv4/esp4_offload.c:41:7: warning: Although the value stored to 'err' is used in the enclosing expression, the value is never actually read from 'err'
No functional change, only more efficient.
--- net/ipv4/esp4_offload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/ipv4/esp4_offload.c +1 -2
@@ -33,12 +33,11 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head,struct xfrm_state *x;__be32 seq;__be32 spi; -int err;if (!pskb_pull (skb, offset))return NULL ; -if ((err =xfrm_parse_spi (skb,IPPROTO_ESP , &spi, &seq)) !=0 ) +if (xfrm_parse_spi (skb,IPPROTO_ESP , &spi, &seq) !=0 ) goto out; xo =xfrm_offload (skb);
Signature · 1 line
2.25.1
Re: [PATCH 01/17] esp: drop unneeded assignment in esp4_gro_receive()
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 6 lines · On Mon, 28 Jun 2021 07:45:06 +0200 you wrote:
From: Yang Li <[email protected]>
Making '!=' operation with 0 directly after calling the function
xfrm_parse_spi()is more efficient, assignment to err is redundant.
Quoted 6 lines
Eliminate the following
clang_analyzerwarning:net/ipv4/esp4_offload.c:41:7: warning: Although the value stored to 'err' is used in the enclosing expression, the value is never actually read from 'err'[...]
Here is the summary with links:
- [01/17] esp: drop unneeded assignment in esp4_gro_receive()
https://git.kernel.org/netdev/net-next/c/335a2a1fcefc - [02/17] xfrm: add state hashtable keyed by seq https://git.kernel.org/netdev/net-next/c/fe9f1d8779cb - [03/17] net: Remove unnecessary variables https://git.kernel.org/netdev/net-next/c/a925316af80a - [04/17] xfrm: remove description from xfrm_type struct https://git.kernel.org/netdev/net-next/c/152bca090243 - [05/17] xfrm: policy: fix a spelling mistake https://git.kernel.org/netdev/net-next/c/7a7ae1eba24a - [06/17] xfrm: ipv6: add xfrm6_hdr_offset helper https://git.kernel.org/netdev/net-next/c/9acf4d3b9ec1 - [07/17] xfrm: ipv6: move mip6_destopt_offset into xfrm core https://git.kernel.org/netdev/net-next/c/37b9e7eb5565 - [08/17] xfrm: ipv6: move mip6_rthdr_offset into xfrm core https://git.kernel.org/netdev/net-next/c/848b18fb7fbd - [09/17] xfrm: remove hdr_offset indirection https://git.kernel.org/netdev/net-next/c/d1002d2490e3 - [10/17] xfrm: merge dstopt and routing hdroff functions https://git.kernel.org/netdev/net-next/c/3ca5ca83e206 - [11/17] xfrm: delete xfrm4_output_finish xfrm6_output_finish declarations https://git.kernel.org/netdev/net-next/c/1b50dd478f49 - [12/17] xfrm: avoid compiler warning when ipv6 is disabled https://git.kernel.org/netdev/net-next/c/30ad6a84f60b - [13/17] xfrm: replay: avoid xfrm replay notify indirection https://git.kernel.org/netdev/net-next/c/cfc61c598e43 - [14/17] xfrm: replay: remove advance indirection https://git.kernel.org/netdev/net-next/c/c7f877833c9f - [15/17] xfrm: replay: remove recheck indirection https://git.kernel.org/netdev/net-next/c/25cfb8bc97c2 - [16/17] xfrm: replay: avoid replay indirection https://git.kernel.org/netdev/net-next/c/adfc2fdbae30 - [17/17] xfrm: replay: remove last replay indirection https://git.kernel.org/netdev/net-next/c/b5a1d1fe0cbb
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Steffen Klassert
maintainerPATCH 2/17 xfrm: add state hashtable keyed by seq
In reply to Steffen KlassertFrom: Sabrina Dubroca <[email protected]>
When creating new states with seq set in xfrm_usersa_info, we walk through all the states already installed in that netns to find a matching ACQUIRE state (__xfrm_find_acq_byseq, called from xfrm_state_add). This causes severe slowdowns on systems with a large number of states.
This patch introduces a hashtable using x->km.seq as key, so that the corresponding state can be found in a reasonable time.
--- include/net/netns/xfrm.h | 1 + include/net/xfrm.h | 1 + net/xfrm/xfrm_hash.h | 7 +++++ net/xfrm/xfrm_state.c | 65 ++++++++++++++++++++++++++++++++-------- 4 files changed, 61 insertions(+), 13 deletions(-)
include/net/netns/xfrm.h +1 -0
@@ -42,6 +42,7 @@ struct netns_xfrm {struct hlist_head __rcu *state_bydst;struct hlist_head __rcu *state_bysrc;struct hlist_head __rcu *state_byspi; +struct hlist_head __rcu *state_byseq;unsigned int state_hmask;unsigned int state_num;struct work_struct state_hash_work;
include/net/xfrm.h +1 -0
@@ -154,6 +154,7 @@ struct xfrm_state { };struct hlist_node bysrc;struct hlist_node byspi; +struct hlist_node byseq;refcount_t refcnt;spinlock_t lock;
net/xfrm/xfrm_hash.h +7 -0
@@ -131,6 +131,13 @@ __xfrm_spi_hash(const xfrm_address_t *daddr, __be32 spi, u8 proto,return (h ^ (h >>10 ) ^ (h >>20 )) & hmask; } +static inline unsigned int +__xfrm_seq_hash (u32 seq,unsigned int hmask) +{ +unsigned int h = seq; +return (h ^ (h >>10 ) ^ (h >>20 )) & hmask; +} +static inline unsigned int __idx_hash (u32 index,unsigned int hmask) {return (index ^ (index >>8 )) & hmask;
net/xfrm/xfrm_state.c +52 -13
164 lines not on this page · raw message
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 3/17 net: Remove unnecessary variables
In reply to Steffen KlassertFrom: zuoqilin <[email protected]>
It is not necessary to define variables to receive -ENOMEM, directly return -ENOMEM.
--- net/key/af_key.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/key/af_key.c +1 -5
@@ -141,7 +141,6 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,struct netns_pfkey *net_pfkey =net_generic (net, pfkey_net_id);struct sock *sk;struct pfkey_sock *pfk; -int err;if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ;
@@ -150,10 +149,9 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,if (protocol !=PF_KEY_V2 )return -EPROTONOSUPPORT ; - err = -ENOMEM ; sk =sk_alloc (net,PF_KEY ,GFP_KERNEL , &key_proto, kern);if (sk ==NULL ) - goto out; +return -ENOMEM ; pfk =pfkey_sk (sk);mutex_init (&pfk->dump_lock);
@@ -169,8 +167,6 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,pfkey_insert (sk);return 0 ; -out: -return err; }static int pfkey_release (struct socket *sock)
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 4/17 xfrm: remove description from xfrm_type struct
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
Its set but never read. Reduces size of xfrm_type to 64 bytes on 64bit.
--- include/net/xfrm.h | 2 -- net/ipv4/ah4.c | 1 - net/ipv4/esp4.c | 1 - net/ipv4/esp4_offload.c | 1 - net/ipv4/ipcomp.c | 1 - net/ipv4/xfrm4_tunnel.c | 1 - net/ipv6/ah6.c | 1 - net/ipv6/esp6.c | 1 - net/ipv6/esp6_offload.c | 1 - net/ipv6/ipcomp6.c | 1 - net/ipv6/mip6.c | 2 -- net/ipv6/xfrm6_tunnel.c | 1 - 12 files changed, 14 deletions(-)
include/net/xfrm.h +0 -2
@@ -388,7 +388,6 @@ void xfrm_flush_gc(void);void xfrm_state_delete_tunnel (struct xfrm_state *x);struct xfrm_type { -char *description;struct module *owner;u8 proto;u8 flags;
@@ -410,7 +409,6 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family);void xfrm_unregister_type (const struct xfrm_type *type,unsigned short family);struct xfrm_type_offload { -char *description;struct module *owner;u8 proto;void (*encap)(struct xfrm_state *,struct sk_buff *pskb);
net/ipv4/ah4.c +0 -1
@@ -554,7 +554,6 @@ static int ah4_rcv_cb(struct sk_buff *skb, int err)static const struct xfrm_type ah_type = { - .description ="AH4" , .owner =THIS_MODULE , .proto =IPPROTO_AH , .flags =XFRM_TYPE_REPLAY_PROT ,
net/ipv4/esp4.c +0 -1
@@ -1198,7 +1198,6 @@ static int esp4_rcv_cb(struct sk_buff *skb, int err)static const struct xfrm_type esp_type = { - .description ="ESP4" , .owner =THIS_MODULE , .proto =IPPROTO_ESP , .flags =XFRM_TYPE_REPLAY_PROT ,
net/ipv4/esp4_offload.c +0 -1
@@ -342,7 +342,6 @@ static const struct net_offload esp4_offload = { };static const struct xfrm_type_offload esp_type_offload = { - .description ="ESP4 OFFLOAD" , .owner =THIS_MODULE , .proto =IPPROTO_ESP , .input_tail = esp_input_tail,
net/ipv4/ipcomp.c +0 -1
@@ -152,7 +152,6 @@ static int ipcomp4_rcv_cb(struct sk_buff *skb, int err) }static const struct xfrm_type ipcomp_type = { - .description ="IPCOMP4" , .owner =THIS_MODULE , .proto =IPPROTO_COMP , .init_state = ipcomp4_init_state,
net/ipv4/xfrm4_tunnel.c +0 -1
@@ -42,7 +42,6 @@ static void ipip_destroy(struct xfrm_state *x) }static const struct xfrm_type ipip_type = { - .description ="IPIP" , .owner =THIS_MODULE , .proto =IPPROTO_IPIP , .init_state = ipip_init_state,
net/ipv6/ah6.c +0 -1
@@ -755,7 +755,6 @@ static int ah6_rcv_cb(struct sk_buff *skb, int err) }static const struct xfrm_type ah6_type = { - .description ="AH6" , .owner =THIS_MODULE , .proto =IPPROTO_AH , .flags =XFRM_TYPE_REPLAY_PROT ,
net/ipv6/esp6.c +0 -1
@@ -1243,7 +1243,6 @@ static int esp6_rcv_cb(struct sk_buff *skb, int err) }static const struct xfrm_type esp6_type = { - .description ="ESP6" , .owner =THIS_MODULE , .proto =IPPROTO_ESP , .flags =XFRM_TYPE_REPLAY_PROT ,
net/ipv6/esp6_offload.c +0 -1
@@ -377,7 +377,6 @@ static const struct net_offload esp6_offload = { };static const struct xfrm_type_offload esp6_type_offload = { - .description ="ESP6 OFFLOAD" , .owner =THIS_MODULE , .proto =IPPROTO_ESP , .input_tail = esp6_input_tail,
net/ipv6/ipcomp6.c +0 -1
@@ -172,7 +172,6 @@ static int ipcomp6_rcv_cb(struct sk_buff *skb, int err) }static const struct xfrm_type ipcomp6_type = { - .description ="IPCOMP6" , .owner =THIS_MODULE , .proto =IPPROTO_COMP , .init_state = ipcomp6_init_state,
net/ipv6/mip6.c +0 -2
@@ -324,7 +324,6 @@ static void mip6_destopt_destroy(struct xfrm_state *x) }static const struct xfrm_type mip6_destopt_type = { - .description ="MIP6DESTOPT" , .owner =THIS_MODULE , .proto =IPPROTO_DSTOPTS , .flags =XFRM_TYPE_NON_FRAGMENT |XFRM_TYPE_LOCAL_COADDR ,
@@ -456,7 +455,6 @@ static void mip6_rthdr_destroy(struct xfrm_state *x) }static const struct xfrm_type mip6_rthdr_type = { - .description ="MIP6RT" , .owner =THIS_MODULE , .proto =IPPROTO_ROUTING , .flags =XFRM_TYPE_NON_FRAGMENT |XFRM_TYPE_REMOTE_COADDR ,
net/ipv6/xfrm6_tunnel.c +0 -1
@@ -291,7 +291,6 @@ static void xfrm6_tunnel_destroy(struct xfrm_state *x) }static const struct xfrm_type xfrm6_tunnel_type = { - .description ="IP6IP6" , .owner =THIS_MODULE , .proto =IPPROTO_IPV6 , .init_state = xfrm6_tunnel_init_state,
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 5/17 xfrm: policy: fix a spelling mistake
In reply to Steffen KlassertFrom: gushengxian <[email protected]>
Fix a spelling mistake.
--- net/xfrm/xfrm_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_policy.c +1 -1
@@ -3247,7 +3247,7 @@ xfrm_state_ok(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x,/* * 0 or more than 0 is returned when validation is succeeded (either bypass -* because of optional transport mode, or next index of the mathced secpath +* because of optional transport mode, or next index of the matched secpath * state with the template. * -1 is returned when no matching template is found. * Otherwise "-2 - errored_index" is returned.
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 6/17 xfrm: ipv6: add xfrm6_hdr_offset helper
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
This moves the ->hdr_offset indirect call to a new helper.
A followup patch can then modify the new function to replace the indirect call by direct calls to the required hdr_offset helper.
--- net/xfrm/xfrm_output.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/xfrm/xfrm_output.c +7 -2
@@ -77,6 +77,11 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)return 0 ; } +static int xfrm6_hdr_offset (struct xfrm_state *x,struct sk_buff *skb,u8 **prevhdr) +{ +return x->type->hdr_offset (x, skb, prevhdr); +} +/* Add encapsulation header. * * The IP header and mutable extension headers will be moved forward to make
@@ -92,7 +97,7 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb) iph =ipv6_hdr (skb);skb_set_inner_transport_header (skb,skb_transport_offset (skb)); - hdr_len = x->type->hdr_offset (x, skb, &prevhdr); + hdr_len =xfrm6_hdr_offset (x, skb, &prevhdr);if (hdr_len <0 )return hdr_len; skb_set_mac_header(skb,
@@ -122,7 +127,7 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb) iph =ipv6_hdr (skb); - hdr_len = x->type->hdr_offset (x, skb, &prevhdr); + hdr_len =xfrm6_hdr_offset (x, skb, &prevhdr);if (hdr_len <0 )return hdr_len; skb_set_mac_header(skb,
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 7/17 xfrm: ipv6: move mip6_destopt_offset into xfrm core
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
This helper is relatively small, just move this to the xfrm core and call it directly.
Next patch does the same for the ROUTING type.
--- net/ipv6/mip6.c | 49 ------------------------------------ net/xfrm/xfrm_output.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 49 deletions(-)
net/ipv6/mip6.c +0 -49
@@ -247,54 +247,6 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb,return err; } -static int mip6_destopt_offset (struct xfrm_state *x,struct sk_buff *skb, -u8 **nexthdr) -{ -u16 offset =sizeof (struct ipv6hdr ); -struct ipv6_opt_hdr *exthdr = - (struct ipv6_opt_hdr *)(ipv6_hdr (skb) +1 ); -const unsigned char *nh =skb_network_header (skb); -unsigned int packet_len =skb_tail_pointer (skb) - -skb_network_header (skb); -int found_rhdr =0 ; - - *nexthdr = &ipv6_hdr (skb)->nexthdr; - -while (offset +1 <= packet_len) { - -switch (**nexthdr) { -case NEXTHDR_HOP : -break ; -case NEXTHDR_ROUTING : - found_rhdr =1 ; -break ; -case NEXTHDR_DEST : -/* -* HAO MUST NOT appear more than once. -* XXX: It is better to try to find by the end of -* XXX: packet if HAO exists. -*/ -if (ipv6_find_tlv (skb, offset,IPV6_TLV_HAO ) >=0 ) { -net_dbg_ratelimited ("mip6: hao exists already, override\n" ); -return offset; - } - -if (found_rhdr) -return offset; - -break ; -default : -return offset; - } - - offset +=ipv6_optlen (exthdr); - *nexthdr = &exthdr->nexthdr; - exthdr = (struct ipv6_opt_hdr *)(nh + offset); - } - -return offset; -} -static int mip6_destopt_init_state (struct xfrm_state *x) {if (x->id.spi) {
@@ -332,7 +284,6 @@ static const struct xfrm_type mip6_destopt_type = { .input = mip6_destopt_input, .output = mip6_destopt_output, .reject = mip6_destopt_reject, - .hdr_offset = mip6_destopt_offset, };static int mip6_rthdr_input (struct xfrm_state *x,struct sk_buff *skb)
net/xfrm/xfrm_output.c +57 -0
65 lines not on this page · raw message
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 8/17 xfrm: ipv6: move mip6_rthdr_offset into xfrm core
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
Place the call into the xfrm core. After this all remaining users set the hdr_offset function pointer to the same function which opens the possiblity to remove the indirection.
--- net/ipv6/mip6.c | 48 ----------------------------------------- net/xfrm/xfrm_output.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 48 deletions(-)
net/ipv6/mip6.c +0 -48
@@ -333,53 +333,6 @@ static int mip6_rthdr_output(struct xfrm_state *x, struct sk_buff *skb)return 0 ; } -static int mip6_rthdr_offset (struct xfrm_state *x,struct sk_buff *skb, -u8 **nexthdr) -{ -u16 offset =sizeof (struct ipv6hdr ); -struct ipv6_opt_hdr *exthdr = - (struct ipv6_opt_hdr *)(ipv6_hdr (skb) +1 ); -const unsigned char *nh =skb_network_header (skb); -unsigned int packet_len =skb_tail_pointer (skb) - -skb_network_header (skb); -int found_rhdr =0 ; - - *nexthdr = &ipv6_hdr (skb)->nexthdr; - -while (offset +1 <= packet_len) { - -switch (**nexthdr) { -case NEXTHDR_HOP : -break ; -case NEXTHDR_ROUTING : -if (offset +3 <= packet_len) { -struct ipv6_rt_hdr *rt; - rt = (struct ipv6_rt_hdr *)(nh + offset); -if (rt->type !=0 ) -return offset; - } - found_rhdr =1 ; -break ; -case NEXTHDR_DEST : -if (ipv6_find_tlv (skb, offset,IPV6_TLV_HAO ) >=0 ) -return offset; - -if (found_rhdr) -return offset; - -break ; -default : -return offset; - } - - offset +=ipv6_optlen (exthdr); - *nexthdr = &exthdr->nexthdr; - exthdr = (struct ipv6_opt_hdr *)(nh + offset); - } - -return offset; -} -static int mip6_rthdr_init_state (struct xfrm_state *x) {if (x->id.spi) {
@@ -413,7 +366,6 @@ static const struct xfrm_type mip6_rthdr_type = { .destructor = mip6_rthdr_destroy, .input = mip6_rthdr_input, .output = mip6_rthdr_output, - .hdr_offset = mip6_rthdr_offset, };static int __init mip6_init (void )
net/xfrm/xfrm_output.c +49 -0
61 lines not on this page · raw message
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 9/17 xfrm: remove hdr_offset indirection
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
After previous patches all remaining users set the function pointer to the same function: xfrm6_find_1stfragopt.
So remove this function pointer and call ip6_find_1stfragopt directly.
Reduces size of xfrm_type to 64 bytes on 64bit platforms.
--- include/net/xfrm.h | 3 --- net/ipv6/ah6.c | 1 - net/ipv6/esp6.c | 1 - net/ipv6/ipcomp6.c | 1 - net/ipv6/xfrm6_output.c | 7 ------- net/xfrm/xfrm_output.c | 2 +- 6 files changed, 1 insertion(+), 14 deletions(-)
include/net/xfrm.h +0 -3
@@ -402,7 +402,6 @@ struct xfrm_type {int (*output)(struct xfrm_state *,struct sk_buff *pskb);int (*reject)(struct xfrm_state *,struct sk_buff *,const struct flowi *); -int (*hdr_offset)(struct xfrm_state *,struct sk_buff *,u8 **); };int xfrm_register_type (const struct xfrm_type *type,unsigned short family);
@@ -1605,8 +1604,6 @@ __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr);__be32 xfrm6_tunnel_spi_lookup (struct net *net,const xfrm_address_t *saddr);int xfrm6_output (struct net *net,struct sock *sk,struct sk_buff *skb);int xfrm6_output_finish (struct sock *sk,struct sk_buff *skb); -int xfrm6_find_1stfragopt (struct xfrm_state *x,struct sk_buff *skb, -u8 **prevhdr);#ifdef CONFIG_XFRM void xfrm6_local_rxpmtu (struct sk_buff *skb,u32 mtu);
net/ipv6/ah6.c +0 -1
@@ -762,7 +762,6 @@ static const struct xfrm_type ah6_type = { .destructor = ah6_destroy, .input = ah6_input, .output = ah6_output, - .hdr_offset = xfrm6_find_1stfragopt, };static struct xfrm6_protocol ah6_protocol = {
net/ipv6/esp6.c +0 -1
@@ -1250,7 +1250,6 @@ static const struct xfrm_type esp6_type = { .destructor = esp6_destroy, .input = esp6_input, .output = esp6_output, - .hdr_offset = xfrm6_find_1stfragopt, };static struct xfrm6_protocol esp6_protocol = {
net/ipv6/ipcomp6.c +0 -1
@@ -178,7 +178,6 @@ static const struct xfrm_type ipcomp6_type = { .destructor = ipcomp_destroy, .input = ipcomp_input, .output = ipcomp_output, - .hdr_offset = xfrm6_find_1stfragopt, };static struct xfrm6_protocol ipcomp6_protocol = {
net/ipv6/xfrm6_output.c +0 -7
@@ -16,13 +16,6 @@#include <net/ip6_route.h> #include <net/xfrm.h> -int xfrm6_find_1stfragopt (struct xfrm_state *x,struct sk_buff *skb, -u8 **prevhdr) -{ -return ip6_find_1stfragopt (skb, prevhdr); -} -EXPORT_SYMBOL (xfrm6_find_1stfragopt); -void xfrm6_local_rxpmtu (struct sk_buff *skb,u32 mtu) {struct flowi6 fl6;
net/xfrm/xfrm_output.c +1 -1
@@ -185,7 +185,7 @@ static int xfrm6_hdr_offset(struct xfrm_state *x, struct sk_buff *skb, u8 **prevbreak ; } -return x->type->hdr_offset (x, skb, prevhdr); +return ip6_find_1stfragopt (skb, prevhdr); }/* Add encapsulation header.
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 10/17 xfrm: merge dstopt and routing hdroff functions
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
Both functions are very similar, so merge them into one.
The nexthdr is passed as argument to break the loop in the ROUTING case, this is the only header type where slightly different rules apply.
While at it, the merged function is realigned with ip6_find_1stfragopt(). That function received bug fixes for an infinite loop, but neither dstopt nor rh parsing functions (copy-pasted from ip6_find_1stfragopt) were changed.
--- net/xfrm/xfrm_output.c | 80 ++++++++++++------------------------------ 1 file changed, 22 insertions(+), 58 deletions(-)
net/xfrm/xfrm_output.c +22 -58
@@ -78,24 +78,30 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb) }#if IS_ENABLED (CONFIG_IPV6_MIP6 ) -static int mip6_destopt_offset (struct xfrm_state *x,struct sk_buff *skb, -u8 **nexthdr) +static int mip6_rthdr_offset (struct sk_buff *skb,u8 **nexthdr,int type) { -u16 offset =sizeof (struct ipv6hdr ); -struct ipv6_opt_hdr *exthdr = - (struct ipv6_opt_hdr *)(ipv6_hdr (skb) +1 );const unsigned char *nh =skb_network_header (skb); -unsigned int packet_len =skb_tail_pointer (skb) - -skb_network_header (skb); +unsigned int offset =sizeof (struct ipv6hdr ); +unsigned int packet_len;int found_rhdr =0 ; + packet_len =skb_tail_pointer (skb) - nh; *nexthdr = &ipv6_hdr (skb)->nexthdr; -while (offset +1 <= packet_len) { +while (offset <= packet_len) { +struct ipv6_opt_hdr *exthdr; +switch (**nexthdr) {case NEXTHDR_HOP :break ;case NEXTHDR_ROUTING : +if (type ==IPPROTO_ROUTING && offset +3 <= packet_len) { +struct ipv6_rt_hdr *rt; + + rt = (struct ipv6_rt_hdr *)(nh + offset); +if (rt->type !=0 ) +return offset; + } found_rhdr =1 ;break ;case NEXTHDR_DEST :
@@ -116,59 +122,18 @@ static int mip6_destopt_offset(struct xfrm_state *x, struct sk_buff *skb, return offset; } - offset +=ipv6_optlen (exthdr); - *nexthdr = &exthdr->nexthdr; - exthdr = (struct ipv6_opt_hdr *)(nh + offset); - } - -return offset; -} - -static int mip6_rthdr_offset (struct xfrm_state *x,struct sk_buff *skb, -u8 **nexthdr) -{ -u16 offset =sizeof (struct ipv6hdr ); -struct ipv6_opt_hdr *exthdr = - (struct ipv6_opt_hdr *)(ipv6_hdr (skb) +1 ); -const unsigned char *nh =skb_network_header (skb); -unsigned int packet_len =skb_tail_pointer (skb) - -skb_network_header (skb); -int found_rhdr =0 ; - - *nexthdr = &ipv6_hdr (skb)->nexthdr; - -while (offset +1 <= packet_len) { -switch (**nexthdr) { -case NEXTHDR_HOP : -break ; -case NEXTHDR_ROUTING : -if (offset +3 <= packet_len) { -struct ipv6_rt_hdr *rt; - - rt = (struct ipv6_rt_hdr *)(nh + offset); -if (rt->type !=0 ) -return offset; - } - found_rhdr =1 ; -break ; -case NEXTHDR_DEST : -if (ipv6_find_tlv (skb, offset,IPV6_TLV_HAO ) >=0 ) -return offset; - -if (found_rhdr) -return offset; - -break ; -default : -return offset; - } +if (offset +sizeof (struct ipv6_opt_hdr ) > packet_len) +return -EINVAL ; + exthdr = (struct ipv6_opt_hdr *)(skb_network_header (skb) + + offset); offset +=ipv6_optlen (exthdr); +if (offset >IPV6_MAXPLEN ) +return -EINVAL ; *nexthdr = &exthdr->nexthdr; - exthdr = (struct ipv6_opt_hdr *)(nh + offset); } -return offset; +return -EINVAL ; }#endif
@@ -177,9 +142,8 @@ static int xfrm6_hdr_offset(struct xfrm_state *x, struct sk_buff *skb, u8 **prevswitch (x->type->proto) {#if IS_ENABLED (CONFIG_IPV6_MIP6 )case IPPROTO_DSTOPTS : -return mip6_destopt_offset (x, skb, prevhdr);case IPPROTO_ROUTING : -return mip6_rthdr_offset (x, skb, prevhdr); +return mip6_rthdr_offset (skb, prevhdr, x->type->proto);#endif default :break ;
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 11/17 xfrm: delete xfrm4_output_finish xfrm6_output_finish declarations
In reply to Steffen KlassertFrom: Antony Antony <[email protected]>
These function declarations are not needed any more. The definitions were deleted.
--- include/net/xfrm.h | 2 -- 1 file changed, 2 deletions(-)
include/net/xfrm.h +0 -2
@@ -1579,7 +1579,6 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) }int xfrm4_output (struct net *net,struct sock *sk,struct sk_buff *skb); -int xfrm4_output_finish (struct sock *sk,struct sk_buff *skb);int xfrm4_protocol_register (struct xfrm4_protocol *handler,unsigned char protocol);int xfrm4_protocol_deregister (struct xfrm4_protocol *handler,unsigned char protocol);int xfrm4_tunnel_register (struct xfrm_tunnel *handler,unsigned short family);
@@ -1603,7 +1602,6 @@ int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family)__be32 xfrm6_tunnel_alloc_spi (struct net *net,xfrm_address_t *saddr);__be32 xfrm6_tunnel_spi_lookup (struct net *net,const xfrm_address_t *saddr);int xfrm6_output (struct net *net,struct sock *sk,struct sk_buff *skb); -int xfrm6_output_finish (struct sock *sk,struct sk_buff *skb);#ifdef CONFIG_XFRM void xfrm6_local_rxpmtu (struct sk_buff *skb,u32 mtu);
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 12/17 xfrm: avoid compiler warning when ipv6 is disabled
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
with CONFIG_IPV6=n:
xfrm_output.c:140:12: warning: 'xfrm6_hdr_offset' defined but not used
--- net/xfrm/xfrm_output.c | 2 ++ 1 file changed, 2 insertions(+)
net/xfrm/xfrm_output.c +2 -0
@@ -137,6 +137,7 @@ static int mip6_rthdr_offset(struct sk_buff *skb, u8 **nexthdr, int type) }#endif +#if IS_ENABLED (CONFIG_IPV6 )static int xfrm6_hdr_offset (struct xfrm_state *x,struct sk_buff *skb,u8 **prevhdr) {switch (x->type->proto) {
@@ -151,6 +152,7 @@ static int xfrm6_hdr_offset(struct xfrm_state *x, struct sk_buff *skb, u8 **prev return ip6_find_1stfragopt(skb, prevhdr); } +#endif /* Add encapsulation header. *
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 13/17 xfrm: replay: avoid xfrm replay notify indirection
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
replay protection is implemented using a callback structure and then called via
x->repl->notify(), x->repl->recheck(), and so on.
all the differect functions are always built-in, so this could be direct calls instead.
This first patch prepares for removal of the x->repl structure. Add an enum with the three available replay modes to the xfrm_state structure and then replace all x->repl->notify() calls by the new xfrm_replay_notify() helper.
The helper checks the enum internally to adapt behaviour as needed.
--- include/net/xfrm.h | 11 ++++++++++- net/xfrm/xfrm_replay.c | 45 ++++++++++++++++++++++++++---------------- net/xfrm/xfrm_state.c | 2 +- 3 files changed, 39 insertions(+), 19 deletions(-)
include/net/xfrm.h +10 -1
@@ -145,6 +145,12 @@ enum { XFRM_MODE_FLAG_TUNNEL = 1, }; +enum xfrm_replay_mode { +XFRM_REPLAY_MODE_LEGACY , +XFRM_REPLAY_MODE_BMP , +XFRM_REPLAY_MODE_ESN , +}; +/* Full description of state of transformer. */ struct xfrm_state {possible_net_t xs_net;
@@ -218,6 +224,8 @@ struct xfrm_state {/* The functions for replay detection. */ const struct xfrm_replay *repl; +/* replay detection mode */ +enum xfrm_replay_mode repl_mode;/* internal flag that only holds state for delayed aevent at the * moment */
@@ -305,7 +313,6 @@ struct xfrm_replay {int (*recheck)(struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq); -void (*notify)(struct xfrm_state *x,int event);int (*overflow)(struct xfrm_state *x,struct sk_buff *skb); };
@@ -1715,6 +1722,8 @@ static inline int xfrm_policy_id2dir(u32 index) }#ifdef CONFIG_XFRM +void xfrm_replay_notify (struct xfrm_state *x,int event); +static inline int xfrm_aevent_is_on (struct net *net) {struct sock *nlsk;
net/xfrm/xfrm_replay.c +28 -17
158 lines not on this page · raw message
net/xfrm/xfrm_state.c +1 -1
@@ -2177,7 +2177,7 @@ static void xfrm_replay_timer_handler(struct timer_list *t)if (x->km.state ==XFRM_STATE_VALID ) {if (xfrm_aevent_is_on (xs_net (x))) - x->repl->notify (x,XFRM_REPLAY_TIMEOUT ); +xfrm_replay_notify (x,XFRM_REPLAY_TIMEOUT );else x->xflags |=XFRM_TIME_DEFER ; }
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 14/17 xfrm: replay: remove advance indirection
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
Similar to other patches: add a new helper to avoid an indirection.
v2: fix 'net/xfrm/xfrm_replay.c:519:13: warning: 'seq' may be used uninitialized in this function' warning.
--- include/net/xfrm.h | 2 +- net/xfrm/xfrm_input.c | 2 +- net/xfrm/xfrm_replay.c | 24 +++++++++++++++--------- 3 files changed, 17 insertions(+), 11 deletions(-)
include/net/xfrm.h +1 -1
@@ -306,7 +306,6 @@ struct km_event { };struct xfrm_replay { -void (*advance)(struct xfrm_state *x,__be32 net_seq);int (*check)(struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq);
@@ -1722,6 +1721,7 @@ static inline int xfrm_policy_id2dir(u32 index) }#ifdef CONFIG_XFRM +void xfrm_replay_advance (struct xfrm_state *x,__be32 net_seq);void xfrm_replay_notify (struct xfrm_state *x,int event);static inline int xfrm_aevent_is_on (struct net *net)
net/xfrm/xfrm_input.c +1 -1
@@ -665,7 +665,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) goto drop_unlock; } - x->repl->advance (x, seq); +xfrm_replay_advance (x, seq); x->curlft.bytes += skb->len; x->curlft.packets++;
net/xfrm/xfrm_replay.c +15 -9
@@ -150,14 +150,26 @@ static int xfrm_replay_check(struct xfrm_state *x,return -EINVAL ; } -static void xfrm_replay_advance (struct xfrm_state *x,__be32 net_seq) +static void xfrm_replay_advance_bmp (struct xfrm_state *x,__be32 net_seq); +static void xfrm_replay_advance_esn (struct xfrm_state *x,__be32 net_seq); + +void xfrm_replay_advance (struct xfrm_state *x,__be32 net_seq) { -u32 diff; -u32 seq =ntohl (net_seq); +u32 diff, seq; + +switch (x->repl_mode) { +case XFRM_REPLAY_MODE_LEGACY : +break ; +case XFRM_REPLAY_MODE_BMP : +return xfrm_replay_advance_bmp (x, net_seq); +case XFRM_REPLAY_MODE_ESN : +return xfrm_replay_advance_esn (x, net_seq); + }if (!x->props.replay_window)return ; + seq =ntohl (net_seq);if (seq > x->replay.seq) { diff = seq - x->replay.seq;if (diff < x->props.replay_window)
@@ -695,42 +707,36 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff }static const struct xfrm_replay xfrm_replay_legacy = { - .advance = xfrm_replay_advance, .check = xfrm_replay_check, .recheck = xfrm_replay_check, .overflow = xfrm_replay_overflow_offload, };static const struct xfrm_replay xfrm_replay_bmp = { - .advance = xfrm_replay_advance_bmp, .check = xfrm_replay_check_bmp, .recheck = xfrm_replay_check_bmp, .overflow = xfrm_replay_overflow_offload_bmp, };static const struct xfrm_replay xfrm_replay_esn = { - .advance = xfrm_replay_advance_esn, .check = xfrm_replay_check_esn, .recheck = xfrm_replay_recheck_esn, .overflow = xfrm_replay_overflow_offload_esn, };#else static const struct xfrm_replay xfrm_replay_legacy = { - .advance = xfrm_replay_advance, .check = xfrm_replay_check, .recheck = xfrm_replay_check, .overflow = xfrm_replay_overflow, };static const struct xfrm_replay xfrm_replay_bmp = { - .advance = xfrm_replay_advance_bmp, .check = xfrm_replay_check_bmp, .recheck = xfrm_replay_check_bmp, .overflow = xfrm_replay_overflow_bmp, };static const struct xfrm_replay xfrm_replay_esn = { - .advance = xfrm_replay_advance_esn, .check = xfrm_replay_check_esn, .recheck = xfrm_replay_recheck_esn, .overflow = xfrm_replay_overflow_esn,
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 15/17 xfrm: replay: remove recheck indirection
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
Adds new xfrm_replay_recheck() helper and calls it from xfrm input path instead of the indirection.
--- include/net/xfrm.h | 4 +--- net/xfrm/xfrm_input.c | 2 +- net/xfrm/xfrm_replay.c | 22 ++++++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-)
include/net/xfrm.h +1 -3
@@ -309,9 +309,6 @@ struct xfrm_replay {int (*check)(struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq); -int (*recheck)(struct xfrm_state *x, -struct sk_buff *skb, -__be32 net_seq);int (*overflow)(struct xfrm_state *x,struct sk_buff *skb); };
@@ -1723,6 +1720,7 @@ static inline int xfrm_policy_id2dir(u32 index)#ifdef CONFIG_XFRM void xfrm_replay_advance (struct xfrm_state *x,__be32 net_seq);void xfrm_replay_notify (struct xfrm_state *x,int event); +int xfrm_replay_recheck (struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq);static inline int xfrm_aevent_is_on (struct net *net) {
net/xfrm/xfrm_input.c +1 -1
@@ -660,7 +660,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)/* only the first xfrm gets the encap type */ encap_type =0 ; -if (x->repl->recheck (x, skb, seq)) { +if (xfrm_replay_recheck (x, skb, seq)) {XFRM_INC_STATS (net,LINUX_MIB_XFRMINSTATESEQERROR ); goto drop_unlock; }
net/xfrm/xfrm_replay.c +16 -6
@@ -519,6 +519,22 @@ static int xfrm_replay_recheck_esn(struct xfrm_state *x,return xfrm_replay_check_esn (x, skb, net_seq); } +int xfrm_replay_recheck (struct xfrm_state *x, +struct sk_buff *skb,__be32 net_seq) +{ +switch (x->repl_mode) { +case XFRM_REPLAY_MODE_LEGACY : +break ; +case XFRM_REPLAY_MODE_BMP : +/* no special recheck treatment */ +return xfrm_replay_check_bmp (x, skb, net_seq); +case XFRM_REPLAY_MODE_ESN : +return xfrm_replay_recheck_esn (x, skb, net_seq); + } + +return xfrm_replay_check (x, skb, net_seq); +} +static void xfrm_replay_advance_esn (struct xfrm_state *x,__be32 net_seq) {unsigned int bitnr, nr, i;
@@ -708,37 +724,31 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buffstatic const struct xfrm_replay xfrm_replay_legacy = { .check = xfrm_replay_check, - .recheck = xfrm_replay_check, .overflow = xfrm_replay_overflow_offload, };static const struct xfrm_replay xfrm_replay_bmp = { .check = xfrm_replay_check_bmp, - .recheck = xfrm_replay_check_bmp, .overflow = xfrm_replay_overflow_offload_bmp, };static const struct xfrm_replay xfrm_replay_esn = { .check = xfrm_replay_check_esn, - .recheck = xfrm_replay_recheck_esn, .overflow = xfrm_replay_overflow_offload_esn, };#else static const struct xfrm_replay xfrm_replay_legacy = { .check = xfrm_replay_check, - .recheck = xfrm_replay_check, .overflow = xfrm_replay_overflow, };static const struct xfrm_replay xfrm_replay_bmp = { .check = xfrm_replay_check_bmp, - .recheck = xfrm_replay_check_bmp, .overflow = xfrm_replay_overflow_bmp, };static const struct xfrm_replay xfrm_replay_esn = { .check = xfrm_replay_check_esn, - .recheck = xfrm_replay_recheck_esn, .overflow = xfrm_replay_overflow_esn, };#endif
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 16/17 xfrm: replay: avoid replay indirection
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
Add and use xfrm_replay_check helper instead of indirection.
--- include/net/xfrm.h | 4 +--- net/xfrm/xfrm_input.c | 2 +- net/xfrm/xfrm_replay.c | 27 ++++++++++++++++++--------- 3 files changed, 20 insertions(+), 13 deletions(-)
include/net/xfrm.h +1 -3
@@ -306,9 +306,6 @@ struct km_event { };struct xfrm_replay { -int (*check)(struct xfrm_state *x, -struct sk_buff *skb, -__be32 net_seq);int (*overflow)(struct xfrm_state *x,struct sk_buff *skb); };
@@ -1719,6 +1716,7 @@ static inline int xfrm_policy_id2dir(u32 index)#ifdef CONFIG_XFRM void xfrm_replay_advance (struct xfrm_state *x,__be32 net_seq); +int xfrm_replay_check (struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq);void xfrm_replay_notify (struct xfrm_state *x,int event);int xfrm_replay_recheck (struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq);
net/xfrm/xfrm_input.c +1 -1
@@ -612,7 +612,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) goto drop_unlock; } -if (x->repl->check (x, skb, seq)) { +if (xfrm_replay_check (x, skb, seq)) {XFRM_INC_STATS (net,LINUX_MIB_XFRMINSTATESEQERROR ); goto drop_unlock; }
net/xfrm/xfrm_replay.c +18 -9
@@ -118,8 +118,8 @@ static int xfrm_replay_overflow(struct xfrm_state *x, struct sk_buff *skb)return err; } -static int xfrm_replay_check (struct xfrm_state *x, -struct sk_buff *skb,__be32 net_seq) +static int xfrm_replay_check_legacy (struct xfrm_state *x, +struct sk_buff *skb,__be32 net_seq) {u32 diff;u32 seq =ntohl (net_seq);
@@ -507,6 +507,21 @@ static int xfrm_replay_check_esn(struct xfrm_state *x,return -EINVAL ; } +int xfrm_replay_check (struct xfrm_state *x, +struct sk_buff *skb,__be32 net_seq) +{ +switch (x->repl_mode) { +case XFRM_REPLAY_MODE_LEGACY : +break ; +case XFRM_REPLAY_MODE_BMP : +return xfrm_replay_check_bmp (x, skb, net_seq); +case XFRM_REPLAY_MODE_ESN : +return xfrm_replay_check_esn (x, skb, net_seq); + } + +return xfrm_replay_check_legacy (x, skb, net_seq); +} +static int xfrm_replay_recheck_esn (struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq) {
@@ -532,7 +547,7 @@ int xfrm_replay_recheck(struct xfrm_state *x,return xfrm_replay_recheck_esn (x, skb, net_seq); } -return xfrm_replay_check (x, skb, net_seq); +return xfrm_replay_check_legacy (x, skb, net_seq); }static void xfrm_replay_advance_esn (struct xfrm_state *x,__be32 net_seq)
@@ -723,32 +738,26 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff }static const struct xfrm_replay xfrm_replay_legacy = { - .check = xfrm_replay_check, .overflow = xfrm_replay_overflow_offload, };static const struct xfrm_replay xfrm_replay_bmp = { - .check = xfrm_replay_check_bmp, .overflow = xfrm_replay_overflow_offload_bmp, };static const struct xfrm_replay xfrm_replay_esn = { - .check = xfrm_replay_check_esn, .overflow = xfrm_replay_overflow_offload_esn, };#else static const struct xfrm_replay xfrm_replay_legacy = { - .check = xfrm_replay_check, .overflow = xfrm_replay_overflow, };static const struct xfrm_replay xfrm_replay_bmp = { - .check = xfrm_replay_check_bmp, .overflow = xfrm_replay_overflow_bmp, };static const struct xfrm_replay xfrm_replay_esn = { - .check = xfrm_replay_check_esn, .overflow = xfrm_replay_overflow_esn, };#endif
Signature · 1 line
2.25.1
Steffen Klassert
maintainerPATCH 17/17 xfrm: replay: remove last replay indirection
In reply to Steffen KlassertFrom: Florian Westphal <[email protected]>
This replaces the overflow indirection with the new xfrm_replay_overflow helper. After this, the 'repl' pointer in xfrm_state is no longer needed and can be removed as well.
xfrm_replay_overflow() is added in two incarnations, one is used when the kernel is compiled with xfrm hardware offload support enabled, the other when its disabled.
--- include/net/xfrm.h | 8 +------ net/xfrm/xfrm_output.c | 2 +- net/xfrm/xfrm_replay.c | 51 +++++++++++++++++++++--------------------- 3 files changed, 28 insertions(+), 33 deletions(-)
include/net/xfrm.h +1 -7
@@ -221,9 +221,6 @@ struct xfrm_state {struct xfrm_replay_state preplay;struct xfrm_replay_state_esn *preplay_esn; -/* The functions for replay detection. */ -const struct xfrm_replay *repl; -/* replay detection mode */ enum xfrm_replay_mode repl_mode;/* internal flag that only holds state for delayed aevent at the
@@ -305,10 +302,6 @@ struct km_event {struct net *net; }; -struct xfrm_replay { -int (*overflow)(struct xfrm_state *x,struct sk_buff *skb); -}; -struct xfrm_if_cb {struct xfrm_if *(*decode_session)(struct sk_buff *skb,unsigned short family);
@@ -1718,6 +1711,7 @@ static inline int xfrm_policy_id2dir(u32 index)void xfrm_replay_advance (struct xfrm_state *x,__be32 net_seq);int xfrm_replay_check (struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq);void xfrm_replay_notify (struct xfrm_state *x,int event); +int xfrm_replay_overflow (struct xfrm_state *x,struct sk_buff *skb);int xfrm_replay_recheck (struct xfrm_state *x,struct sk_buff *skb,__be32 net_seq);static inline int xfrm_aevent_is_on (struct net *net)
net/xfrm/xfrm_output.c +1 -1
@@ -525,7 +525,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err) goto error; } - err = x->repl->overflow (x, skb); + err =xfrm_replay_overflow (x, skb);if (err) {XFRM_INC_STATS (net,LINUX_MIB_XFRMOUTSTATESEQERROR ); goto error;
net/xfrm/xfrm_replay.c +26 -25
83 lines not on this page · raw message
Signature · 1 line
2.25.1
This pull request was applied to netdev/net-next.git (refs/heads/master):
Hello:
This pull request was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Mon, 28 Jun 2021 07:45:05 +0200 you wrote:
1) Remove an unneeded error assignment in
esp4_gro_receive(). From Yang Li.2) Add a new byseq state hashtable to find acquire states faster. From Sabrina Dubroca.
3) Remove some unnecessary variables in
pfkey_create(). From zuoqilin.[...]
Here is the summary with links:
- pull request (net-next): ipsec-next 2021-06-28
https://git.kernel.org/netdev/net-next/c/1b077ce1c5be
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html