Skip to contentSkip to conversation

xfrm: Notify changes in UDP encapsulation via netlink

PATCH Applied Martin Willi 2 participants 5 messages Oct 28, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: Notify changes in UDP encapsulation via netlink

Add new_mapping() implementation to the netlink xfrm_mgr to notify address/port changes detected in UDP encapsulated ESP packets.

include/linux/xfrm.h +14 -0
index 4bc1e6b..52f3abd 100644
@@ -199,6 +199,9 @@ enum {
 #define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO
 	XFRM_MSG_GETSPDINFO,
 #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO
+
+	XFRM_MSG_MAPPING,
+#define XFRM_MSG_MAPPING XFRM_MSG_MAPPING
 	__XFRM_MSG_MAX
 };
 #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1)
@@ -438,6 +441,15 @@ struct xfrm_user_migrate {
 	__u16				new_family;
 };
 
+struct xfrm_user_mapping {
+	struct xfrm_usersa_id		id;
+	__u32				reqid;
+	xfrm_address_t			old_saddr;
+	xfrm_address_t			new_saddr;
+	__be16				old_sport;
+	__be16				new_sport;
+};
+
 #ifndef __KERNEL__
 /* backwards compatibility for userspace */
 #define XFRMGRP_ACQUIRE		1
@@ -464,6 +476,8 @@ enum xfrm_nlgroups {
 #define XFRMNLGRP_REPORT	XFRMNLGRP_REPORT
 	XFRMNLGRP_MIGRATE,
 #define XFRMNLGRP_MIGRATE	XFRMNLGRP_MIGRATE
+	XFRMNLGRP_MAPPING,
+#define XFRMNLGRP_MAPPING	XFRMNLGRP_MAPPING
 	__XFRMNLGRP_MAX
 };
 #define XFRMNLGRP_MAX	(__XFRMNLGRP_MAX - 1)
net/xfrm/xfrm_user.c +52 -0

64 lines not on this page · raw message

maintainer
#1 lore raw

From: [email protected] (Martin Willi)
Date: Tue, 28 Oct 2008 09:51:19 +0100 (CET)

Quoted 4 lines

Add new_mapping() implementation to the netlink xfrm_mgr to notify address/port changes detected in UDP encapsulated ESP packets.

I don't see the code which will actually invoke the new ->new_mapping() method (either here or in a follow-on patch), so it's impossible to review these changes.

#2 lore raw
Quoted 3 lines

I don't see the code which will actually invoke the new ->new_mapping() method (either here or in a follow-on patch), so it's impossible to review these changes.

The patch is complete, sorry for being unclear.

xfrm_send_mapping is an implementation of a xfrm_mgr operation.

Quoted 8 lines

static struct xfrm_mgr netlink_mgr = {

        .id             = "netlink",
        .notify         = xfrm_send_state_notify,
        .notify_policy  = xfrm_send_policy_notify,
        .report         = xfrm_send_report,
        .migrate        = xfrm_send_migrate,
+       .new_mapping    = xfrm_send_mapping,

};

This operation is invoked from net/ipv4/esp4.c through the km_new_mapping() function, km_new_mapping() invokes all registered key managers. It is already implemented in the PF_KEY interface (pfkeyv2_mgr in af_key.c), but is missing in the netlink xfrm interface. The patch adds this functionality to the netlink interface.

maintainer
#3 lore raw

From: Martin Willi <[email protected]>
Date: Tue, 28 Oct 2008 21:44:20 +0100

Quoted 9 lines
Quoted 8 lines

static struct xfrm_mgr netlink_mgr = {

        .id             = "netlink",
        .notify         = xfrm_send_state_notify,
        .notify_policy  = xfrm_send_policy_notify,
        .report         = xfrm_send_report,
        .migrate        = xfrm_send_migrate,
+       .new_mapping    = xfrm_send_mapping,

};

Quoted 5 lines

This operation is invoked from net/ipv4/esp4.c through the km_new_mapping() function, km_new_mapping() invokes all registered key managers. It is already implemented in the PF_KEY interface (pfkeyv2_mgr in af_key.c), but is missing in the netlink xfrm interface. The patch adds this functionality to the netlink interface.

Sorry, I didn't pick up on that. Thanks for the explanation.

maintainer Applied
#4 lore raw
In reply to Martin Willi

From: [email protected] (Martin Willi)
Date: Tue, 28 Oct 2008 09:51:19 +0100 (CET)

Quoted 4 lines

Add new_mapping() implementation to the netlink xfrm_mgr to notify address/port changes detected in UDP encapsulated ESP packets.

Applied, thanks a lot.

net/xfrm/xfrm_user.c static int xfrm_send_report(u8 proto, struct xfrm_selector *sel, · line 2523

Quoted 3 lines
net/xfrm/xfrm_user.c +3 -0
+	um = nlmsg_data(nlh);
+	
+	memcpy(&um->id.daddr, &x->id.daddr, sizeof(um->id.daddr));

That second line has trailing whitespace which I fixed up by hand when applying this patch.

Please avoid this in the future.