From 1ee140b67bc663f5876b391208c30863242d98cb Mon Sep 17 00:00:00 2001
From: Shinta Sugimoto <shinta@sfc.wide.ad.jp>
Date: Wed, 7 Mar 2007 19:14:13 +0900
Subject: [BUGFIX] XFRM: Specify source port mask.

Specify source port mask when non-zero source port is specified.
---
 src/ipsec.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/ipsec.c b/src/ipsec.c
index d92af8b..9f70077 100644
--- a/src/ipsec.c
+++ b/src/ipsec.c
@@ -105,20 +105,23 @@ static void _set_sp(struct xfrm_userpolicy_info *sp,
 
 	switch (e->type) {
 	case IPSEC_POLICY_TYPE_TUNNELHOMETESTING:
-		sp->priority = MIP6_PRIO_RO_SIG_RR;
 		if (dir == XFRM_POLICY_IN) {
-			if (nodetype == MIP6_ENTITY_MN)
+			if (nodetype == MIP6_ENTITY_MN) {
 				sp->sel.sport = htons(IP6_MH_TYPE_HOT);
-			else if (nodetype == MIP6_ENTITY_HA)
+				sp->sel.sport_mask = ~((__u16)0);
+			} else if (nodetype == MIP6_ENTITY_HA) {
 				sp->sel.sport = htons(IP6_MH_TYPE_HOTI);
-			else
+				sp->sel.sport_mask = ~((__u16)0);
+			} else
 				sp->sel.sport = 0;
 		} else if (dir == XFRM_POLICY_OUT) {
-			if (nodetype == MIP6_ENTITY_MN)
+			if (nodetype == MIP6_ENTITY_MN) {
 				sp->sel.sport = htons(IP6_MH_TYPE_HOTI);
-			else if (nodetype == MIP6_ENTITY_HA)
+				sp->sel.sport_mask = ~((__u16)0);
+			} else if (nodetype == MIP6_ENTITY_HA) {
 				sp->sel.sport = htons(IP6_MH_TYPE_HOT);
-			else
+				sp->sel.sport_mask = ~((__u16)0);
+			} else
 				sp->sel.sport = 0;
 		} else {
 			sp->sel.sport = 0;
-- 
1.5.0.3

