Skip to contentSkip to conversation

XFRM: sub policy support.

PATCH In review Masahide NAKAMURA 1 participant 1 message Dec 5, 2006

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

PATCH 4/7 XFRM: sub policy support.

---
 ip/ipxfrm.c      |   27 ++++++++++
 ip/xfrm.h        |    4 +
 ip/xfrm_policy.c |  150 ++++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 164 insertions(+), 17 deletions(-)
ip/ipxfrm.c +27 -0
index 4bcd2f3..79fc133 100644
@@ -709,6 +709,7 @@ void xfrm_policy_info_print(struct xfrm_
 			    const char *title)
 {
 	char buf[STRBUF_SIZE];
+	__u8 ptype = XFRM_POLICY_TYPE_MAIN;
 
 	memset(buf, '\0', sizeof(buf));
 
@@ -752,6 +753,32 @@ void xfrm_policy_info_print(struct xfrm_
 	if (show_stats)
 		fprintf(fp, "index %u ", xpinfo->index);
 	fprintf(fp, "priority %u ", xpinfo->priority);
+
+	fprintf(fp, "ptype ");
+
+	if (tb[XFRMA_POLICY_TYPE]) {
+		struct xfrm_userpolicy_type *upt;
+
+		if (RTA_PAYLOAD(tb[XFRMA_POLICY_TYPE]) < sizeof(*upt))
+			fprintf(fp, "(ERROR truncated)");
+
+		upt = (struct xfrm_userpolicy_type *)RTA_DATA(tb[XFRMA_POLICY_TYPE]);
+		ptype = upt->type;
+	}
+
+	switch (ptype) {
+	case XFRM_POLICY_TYPE_MAIN:
+		fprintf(fp, "main");
+		break;
+	case XFRM_POLICY_TYPE_SUB:
+		fprintf(fp, "sub");
+		break;
+	default:
+		fprintf(fp, "%u", ptype);
+		break;
+	}
+	fprintf(fp, " ");
+
 	if (show_stats > 0) {
 		fprintf(fp, "share %s ", strxf_share(xpinfo->share));
 		fprintf(fp, "flag 0x%s", strxf_mask8(xpinfo->flags));
ip/xfrm.h +4 -0
index 4833b36..7a53e59 100644
@@ -92,6 +92,10 @@ struct xfrm_filter {
 	__u32 index_mask;
 	__u8 action_mask;
 	__u32 priority_mask;
+
+	__u8 ptype;
+	__u8 ptype_mask;
+
 };
 #define XFRM_FILTER_MASK_FULL (~0)
 
ip/xfrm_policy.c +133 -17

283 lines not on this page · raw message

Signature · 1 line
1.4.2