Skip to contentSkip to conversation

pull request (net-next): ipsec-next 2022-03-19

PATCH Applied Steffen Klassert 2 participants 4 messages Mar 19, 2022

Subsystems (3)
lore
Share & tools
lore

Steffen Klassert

author maintainer
#0 lore raw

cover pull request (net-next): ipsec-next 2022-03-19

1) Delete duplicated functions that calls same xfrm_api_check. From Leon Romanovsky.

2) Align userland API of the default policy structure to the internal structures. From Nicolas Dichtel.

Please pull or let me know if there are problems.

Thanks!

The following changes since commit 000fe940e51f03210bd5fb1061d4d82ed9a7b1b6:

sfc: The size of the RX recycle ring should be more flexible (2022-02-01 20:34:59 -0800)

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 b58b1f563ab78955d37e9e43e02790a85c66ac05:

xfrm: rework default policy structure (2022-03-18 07:23:12 +0100)

----------------------------------------------------------------
Leon Romanovsky (1):
xfrm: delete duplicated functions that calls same xfrm_api_check()

Nicolas Dichtel (1):
xfrm: rework default policy structure

 include/net/netns/xfrm.h |  6 +-----
 include/net/xfrm.h       | 48 ++++++++++++++++++------------------------------
 net/xfrm/xfrm_device.c   | 14 ++------------
 net/xfrm/xfrm_policy.c   | 10 +++++++---
 net/xfrm/xfrm_user.c     | 43 ++++++++++++++++++-------------------------
 5 files changed, 46 insertions(+), 75 deletions(-)
author maintainer
#1 lore raw

PATCH 1/2 xfrm: delete duplicated functions that calls same xfrm_api_check()

From: Leon Romanovsky <[email protected]>

The xfrm_dev_register() and xfrm_dev_feat_change() have same implementation of one call to xfrm_api_check(). Instead of doing such indirection, call to xfrm_api_check() directly and delete duplicated functions.

---
 net/xfrm/xfrm_device.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
net/xfrm/xfrm_device.c +2 -12
index 3fa066419d37..36d6c1835844 100644
@@ -380,16 +380,6 @@ static int xfrm_api_check(struct net_device *dev)
 	return NOTIFY_DONE;
 }
 
-static int xfrm_dev_register(struct net_device *dev)
-{
-	return xfrm_api_check(dev);
-}
-
-static int xfrm_dev_feat_change(struct net_device *dev)
-{
-	return xfrm_api_check(dev);
-}
-
 static int xfrm_dev_down(struct net_device *dev)
 {
 	if (dev->features & NETIF_F_HW_ESP)
@@ -404,10 +394,10 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void
 
 	switch (event) {
 	case NETDEV_REGISTER:
-		return xfrm_dev_register(dev);
+		return xfrm_api_check(dev);
 
 	case NETDEV_FEAT_CHANGE:
-		return xfrm_dev_feat_change(dev);
+		return xfrm_api_check(dev);
 
 	case NETDEV_DOWN:
 	case NETDEV_UNREGISTER:
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/2] xfrm: delete duplicated functions that calls same xfrm_api_check()

This series was applied to netdev/net-next.git (master) by Steffen Klassert <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Steffen Klassert <[email protected]>:

Quoted 8 lines · On Sat, 19 Mar 2022 08:42:39 +0100 you wrote:

From: Leon Romanovsky <[email protected]>

The xfrm_dev_register() and xfrm_dev_feat_change() have same implementation of one call to xfrm_api_check(). Instead of doing such indirection, call to xfrm_api_check() directly and delete duplicated functions.

[...]

Here is the summary with links:
- [1/2] xfrm: delete duplicated functions that calls same xfrm_api_check()

    https://git.kernel.org/netdev/net-next/c/2ecda181682e
  - [2/2] xfrm: rework default policy structure
    https://git.kernel.org/netdev/net-next/c/b58b1f563ab7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#3 lore raw

PATCH 2/2 xfrm: rework default policy structure

In reply to Steffen Klassert

From: Nicolas Dichtel <[email protected]>

This is a follow up of commit f8d858e607b2 ("xfrm: make user policy API complete"). The goal is to align userland API to the internal structures.

---
 include/net/netns/xfrm.h |  6 +----
 include/net/xfrm.h       | 48 +++++++++++++++-------------------------
 net/xfrm/xfrm_policy.c   | 10 ++++++---
 net/xfrm/xfrm_user.c     | 43 +++++++++++++++--------------------
 4 files changed, 44 insertions(+), 63 deletions(-)
include/net/netns/xfrm.h +1 -5
index 947733a639a6..bd7c3be4af5d 100644
@@ -66,11 +66,7 @@ struct netns_xfrm {
 	int			sysctl_larval_drop;
 	u32			sysctl_acq_expires;
 
-	u8			policy_default;
-#define XFRM_POL_DEFAULT_IN	1
-#define XFRM_POL_DEFAULT_OUT	2
-#define XFRM_POL_DEFAULT_FWD	4
-#define XFRM_POL_DEFAULT_MASK	7
+	u8			policy_default[XFRM_POLICY_MAX];
 
 #ifdef CONFIG_SYSCTL
 	struct ctl_table_header	*sysctl_hdr;
include/net/xfrm.h +18 -30

69 lines not on this page · raw message

net/xfrm/xfrm_policy.c +7 -3
index 04d1ce9b510f..01fe1e9cff86 100644
@@ -3158,7 +3158,7 @@ struct dst_entry *xfrm_lookup_with_ifid(struct net *net,
 
 nopol:
 	if (!(dst_orig->dev->flags & IFF_LOOPBACK) &&
-	    !xfrm_default_allow(net, dir)) {
+	    net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK) {
 		err = -EPERM;
 		goto error;
 	}
@@ -3569,7 +3569,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
 	}
 
 	if (!pol) {
-		if (!xfrm_default_allow(net, dir)) {
+		if (net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK) {
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOPOLS);
 			return 0;
 		}
@@ -3629,7 +3629,8 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
 		}
 		xfrm_nr = ti;
 
-		if (!xfrm_default_allow(net, dir) && !xfrm_nr) {
+		if (net->xfrm.policy_default[dir] == XFRM_USERPOLICY_BLOCK &&
+		    !xfrm_nr) {
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOSTATES);
 			goto reject;
 		}
@@ -4118,6 +4119,9 @@ static int __net_init xfrm_net_init(struct net *net)
 	spin_lock_init(&net->xfrm.xfrm_policy_lock);
 	seqcount_spinlock_init(&net->xfrm.xfrm_policy_hash_generation, &net->xfrm.xfrm_policy_lock);
 	mutex_init(&net->xfrm.xfrm_cfg_mutex);
+	net->xfrm.policy_default[XFRM_POLICY_IN] = XFRM_USERPOLICY_ACCEPT;
+	net->xfrm.policy_default[XFRM_POLICY_FWD] = XFRM_USERPOLICY_ACCEPT;
+	net->xfrm.policy_default[XFRM_POLICY_OUT] = XFRM_USERPOLICY_ACCEPT;
 
 	rv = xfrm_statistics_init(net);
 	if (rv < 0)
net/xfrm/xfrm_user.c +18 -25

69 lines not on this page · raw message

Signature · 1 line
2.25.1