diff -Nur NEPL-SE-1.0/BUGS NEPL-SE-1.1/BUGS
--- NEPL-SE-1.0/BUGS	2005-11-07 12:26:36.000000000 +0900
+++ NEPL-SE-1.1/BUGS	2005-11-18 15:18:48.000000000 +0900
@@ -1,4 +1,4 @@
-Known issues in NEPL-SE 1.0
+Known issues in NEPL-SE 1.1
 ---------------------------
 
 NEMO issues
@@ -22,6 +22,10 @@
   due to the design of the Linux IPsec implementation.  Read
   README.IPsec for more information.
 
+* There are some issues if the daemon is stopped and restarted while 
+  operating several interfaces at the same time. A reboot or restart 
+  network interfaces may be needed.
+
 Home Agent issues
 -----------------
 
@@ -36,10 +40,11 @@
   UseCnBuAck is turned on. This problem should not arise if the option
   is turned off.
 
-* Multihoming support in the Mobile Node is still under development,
-  so we don't currently recommend defining more than one Interface in
-  the MN configuration file unless you *really* know what you are
-  doing.
+* Multihoming support in the Mobile Node is still under development.
+  It may sometimes not behave as expected. Especially when one or several
+  interfaces are at home, the path may not be coherent. Be aware that the 
+  Home Agent may not have a default route to the interface that is at home.
+  The multihomed MN was not tested with IPsec yet.
 
 * The advanced route optimization policies are likewise under
   development, so the MnRoPolicy configuration options might not work
diff -Nur NEPL-SE-1.0/configure NEPL-SE-1.1/configure
--- NEPL-SE-1.0/configure	2005-11-07 12:33:42.000000000 +0900
+++ NEPL-SE-1.1/configure	2005-11-18 15:08:17.000000000 +0900
@@ -1,7 +1,7 @@
 #! /bin/sh
 # From configure.ac Revision: 1.27 .
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for NEPL NEMO Platform for Linux SE-1.0.
+# Generated by GNU Autoconf 2.59 for NEPL NEMO Platform for Linux SE-1.1.
 #
 # Report bugs to <URL:http://www.mobile-ipv6.org/>.
 #
@@ -270,8 +270,8 @@
 # Identity of this package.
 PACKAGE_NAME='NEPL NEMO Platform for Linux'
 PACKAGE_TARNAME='nemo'
-PACKAGE_VERSION='SE-1.0'
-PACKAGE_STRING='NEPL NEMO Platform for Linux SE-1.0'
+PACKAGE_VERSION='SE-1.1'
+PACKAGE_STRING='NEPL NEMO Platform for Linux SE-1.1'
 PACKAGE_BUGREPORT='URL:http://www.mobile-ipv6.org/'
 
 ac_unique_file="src/main.c"
@@ -781,7 +781,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures NEPL NEMO Platform for Linux SE-1.0 to adapt to many kinds of systems.
+\`configure' configures NEPL NEMO Platform for Linux SE-1.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -843,7 +843,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of NEPL NEMO Platform for Linux SE-1.0:";;
+     short | recursive ) echo "Configuration of NEPL NEMO Platform for Linux SE-1.1:";;
    esac
   cat <<\_ACEOF
 
@@ -963,7 +963,7 @@
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-NEPL NEMO Platform for Linux configure SE-1.0
+NEPL NEMO Platform for Linux configure SE-1.1
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -977,7 +977,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by NEPL NEMO Platform for Linux $as_me SE-1.0, which was
+It was created by NEPL NEMO Platform for Linux $as_me SE-1.1, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1619,7 +1619,7 @@
 
 # Define the identity of the package.
  PACKAGE='nemo'
- VERSION='SE-1.0'
+ VERSION='SE-1.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -7597,7 +7597,7 @@
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by NEPL NEMO Platform for Linux $as_me SE-1.0, which was
+This file was extended by NEPL NEMO Platform for Linux $as_me SE-1.1, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -7660,7 +7660,7 @@
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-NEPL NEMO Platform for Linux config.status SE-1.0
+NEPL NEMO Platform for Linux config.status SE-1.1
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
diff -Nur NEPL-SE-1.0/configure.ac NEPL-SE-1.1/configure.ac
--- NEPL-SE-1.0/configure.ac	2005-11-07 12:26:21.000000000 +0900
+++ NEPL-SE-1.1/configure.ac	2005-11-18 15:07:04.000000000 +0900
@@ -2,7 +2,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.57)
-AC_INIT([NEPL NEMO Platform for Linux], [SE-1.0], 
+AC_INIT([NEPL NEMO Platform for Linux], [SE-1.1], 
 	[URL:http://www.mobile-ipv6.org/], nemo)
 AC_DEFINE_UNQUOTED([PACKAGE_COPYRIGHT],
 	["Copyright (C) 2003-2005 GO-Core Project, and others"], 
diff -Nur NEPL-SE-1.0/man/nemod.conf.tmpl NEPL-SE-1.1/man/nemod.conf.tmpl
--- NEPL-SE-1.0/man/nemod.conf.tmpl	2005-11-02 16:03:04.000000000 +0900
+++ NEPL-SE-1.1/man/nemod.conf.tmpl	2005-11-18 15:17:57.000000000 +0900
@@ -74,12 +74,19 @@
 .B MnIfPreference
 is used with Mobile IPv6.  It sets interface preference value for an
 interface, in a multi-homed mobile node.  Preference is relative only
-to other preference values, and may be a signed number.
+to other preference values, and may be a signed number. The lower the 
+preference is, the prefered is the interface.
 
 .B IsRouter
 and
 .B IfType
-are only used with NEMO.
+are only used with NEMO. When using 
+.B MnIfPreference
+in a multihomed Mobile Router, you have to set 
+.B IfType
+to 
+.B MN
+.
 
 .TP
 .BR "UseMnHaIPsec " "boolean" ";"
@@ -223,6 +230,15 @@
 Default: enabled
 
 .TP
+.BR "MnPreferHome = enabled | disabled"
+
+When the node is multihomed, indicates if an interface that is at home 
+should be prefered to the other interfaces, even if its preference is 
+not the best.
+
+Default: disabled
+
+.TP
 .BR "MobRtrUseExplicitMode = enabled | disabled"
 
 Toggles between explicit or implicit mode home registrations in the MR.
diff -Nur NEPL-SE-1.0/NEWS NEPL-SE-1.1/NEWS
--- NEPL-SE-1.0/NEWS	2005-11-07 12:32:35.000000000 +0900
+++ NEPL-SE-1.1/NEWS	2005-11-18 15:07:20.000000000 +0900
@@ -1,4 +1,4 @@
-NEPL-SE 1.0 is a NEMO Basic implementation for Linux, based on MIPL2
+NEPL-SE 1.1 is a NEMO Basic implementation for Linux, based on MIPL2
 Mobile IPv6 (RC3) for Linux. As such, it supports both MIPv6 and NEMO Basic.
 
 This "Special Edition" release incorporates all MIPv6 fixes made between
diff -Nur NEPL-SE-1.0/src/conf.c NEPL-SE-1.1/src/conf.c
--- NEPL-SE-1.0/src/conf.c	2005-11-01 17:49:26.000000000 +0900
+++ NEPL-SE-1.1/src/conf.c	2005-11-18 12:37:51.000000000 +0900
@@ -212,6 +212,7 @@
 	c->DefaultBindingAclPolicy = IP6_MH_BAS_ACCEPTED;
 	c->UseCnBuAck = 0;
 	c->MnUseAllInterfaces = 0;
+	c->MnPreferHome = 0;
 	c->MnRouterProbesRA = 0;
 	c->MnRouterProbesLinkUp = 0;
 	c->HaAcceptMobRtr = 0;
diff -Nur NEPL-SE-1.0/src/conf.h NEPL-SE-1.1/src/conf.h
--- NEPL-SE-1.0/src/conf.h	2005-11-01 17:50:31.000000000 +0900
+++ NEPL-SE-1.1/src/conf.h	2005-11-18 12:37:15.000000000 +0900
@@ -36,6 +36,7 @@
 	int DefaultBindingAclPolicy;
 	int UseCnBuAck;
 	int MnUseAllInterfaces;
+	int MnPreferHome;
 	int MnRouterProbesRA;
 	int MnRouterProbesLinkUp;
 	int HaAcceptMobRtr;
diff -Nur NEPL-SE-1.0/src/gram.y NEPL-SE-1.1/src/gram.y
--- NEPL-SE-1.0/src/gram.y	2005-11-01 18:04:51.000000000 +0900
+++ NEPL-SE-1.1/src/gram.y	2005-11-18 12:40:34.000000000 +0900
@@ -191,6 +191,7 @@
 %token		ISROUTER
 %token		MNIFPREFERENCE
 %token		MNUSEALLINTERFACES
+%token		MNPREFERHOME
 %token		MNROUTERPROBESRA
 %token		MNROUTERPROBESLINKUP
 %token		MNROUTERPROBETIMEOUT
@@ -321,6 +322,10 @@
 		{
 			conf.MnUseAllInterfaces = $2;
 		}
+		| MNPREFERHOME BOOL ';' 
+		{
+			conf.MnPreferHome = $2;
+		}
 		| MNROUTERPROBESRA NUMBER ';' 
 		{
 			conf.MnRouterProbesRA = $2;
@@ -407,6 +412,7 @@
 			}
 			strncpy(hai.name, $1, IF_NAMESIZE - 1);
 			hai.if_home = if_nametoindex($1);
+			hai.hoa.iif = hai.if_home;
 			free($1);
 			if (hai.plen == 64) {
 				struct in6_addr lladdr;
diff -Nur NEPL-SE-1.0/src/mh_bu.c NEPL-SE-1.1/src/mh_bu.c
--- NEPL-SE-1.0/src/mh_bu.c	2005-11-01 19:59:00.000000000 +0900
+++ NEPL-SE-1.1/src/mh_bu.c	2005-11-09 17:15:35.000000000 +0900
@@ -798,7 +798,7 @@
 		timespeccpy(&bce->lifetime, &lifetime);
 
 		if (new) {
-			if (tunnel_add(our_addr, out_addrs.bind_coa,
+			if (tunnel_add(bce->link, our_addr, out_addrs.bind_coa,
 				       home_tnl_ops, &p) < 0) {
 				syslog(LOG_ERR, "Tunnel creation failed!");
 				if (p.ba_status >= IP6_MH_BAS_UNSPECIFIED)
@@ -835,7 +835,7 @@
 				bcache_complete_homereg(bce);
 			}
 		} else {
-			if (tunnel_mod(bce->tunnel, our_addr, 
+			if (tunnel_mod(bce->tunnel, bce->link, our_addr, 
 				       out_addrs.bind_coa, 
 				       home_tnl_ops, &p) < 0) { 
 				syslog(LOG_ERR, "Tunnel modification failed!");
diff -Nur NEPL-SE-1.0/src/mn.c NEPL-SE-1.1/src/mn.c
--- NEPL-SE-1.0/src/mn.c	2005-11-02 10:57:06.000000000 +0900
+++ NEPL-SE-1.1/src/mn.c	2005-11-18 11:29:03.000000000 +0900
@@ -850,6 +850,7 @@
 
 	/* Before bul_iterate, tunnel modification should be done. */
 	tunnel_mod(hai->if_tunnel,
+		   hai->primary_coa.iif,
 		   &hai->primary_coa.addr,
 		   &hai->ha_addr, 
 		   mn_ext_tunnel_ops,
@@ -1531,8 +1532,10 @@
 		     NIP6ADDR(&hai->ha_addr)); 
 	}
 	ipv6_addr_copy(&hai->primary_coa.addr, &hai->hoa.addr);
+	hai->primary_coa.iif = hai->hoa.iif;
 
-	hai->if_tunnel = tunnel_add(&hai->primary_coa.addr, &hai->ha_addr, 
+	hai->if_tunnel = tunnel_add(hai->primary_coa.iif, 
+				    &hai->primary_coa.addr, &hai->ha_addr, 
 				    NULL, NULL);
 
 	clock_gettime(CLOCK_REALTIME, &now);
@@ -1775,6 +1778,27 @@
 	return -1;
 }
 
+/* This is to set the HoA on an iface in the case when e.g. the iface
+ * was put down when being home. In that case the HoA is removed
+ * automatically from the iface. If at the same time another iface
+ * is available then addr_do() may fail to do mv_hoa().
+ */
+inline static int mn_set_hoa(int iface, struct home_addr_info *hai)
+{
+	int ret = 0;
+	int plen = hai->at_home ? hai->plen : 128;
+	ret = addr_add(&hai->hoa.addr, plen,
+			IFA_F_HOMEADDRESS, 0, iface,
+			0, 0);
+	if (ret < 0) {
+		MDBG("failed with %d on %d\n", ret, iface);
+		return ret;
+	}
+	
+	hai->hoa.iif = iface;
+	return ret;
+}
+
 static int mn_move(struct home_addr_info *hai)
 {
 	struct mv_hoa_args mha;
@@ -1790,8 +1814,9 @@
 
 		if (hai->hoa.iif != hai->primary_coa.iif) {
 			mha.if_next = hai->primary_coa.iif;
-			addr_do(&hai->hoa.addr, plen,
-				hai->hoa.iif, &mha, mv_hoa);
+			if (addr_do(&hai->hoa.addr, plen,
+				hai->hoa.iif, &mha, mv_hoa) < 0)
+				mn_set_hoa(hai->primary_coa.iif, hai);
 			if (hai->home_reg_status == HOME_REG_NONE) {
 				mn_send_home_na(hai);
 				do_handoff(hai, &hai->hoa);
@@ -1811,8 +1836,9 @@
 		}
 		if (hai->hoa.iif != hai->if_tunnel) {
 			mha.if_next = hai->if_tunnel;
-			addr_do(&hai->hoa.addr, hai->plen,
-				hai->hoa.iif, &mha, mv_hoa);
+			if (addr_do(&hai->hoa.addr, hai->plen,
+				hai->hoa.iif, &mha, mv_hoa) < 0)
+				mn_set_hoa(hai->if_tunnel, hai);
 		}
 		do_handoff(hai, &hai->primary_coa);
 	}
@@ -2114,7 +2140,14 @@
 		hai->primary_coa.iif = coa->ifindex;
 		mn_update_coa_lifetime(&hai->primary_coa, coa);
 		mn_coa_updated(hai);
-	} else if (hai->verdict == POLICY_HO_PROCEED) { 
+	} else if (hai->verdict == POLICY_HO_PROCEED) {
+		/* RK - Interface Preference */
+		int changed_iface = 0;
+		if(hai->primary_coa.iif != coa->ifindex){
+			MDBG2("Interface has changed from %d to %d\n", 
+					hai->primary_coa.iif, coa->ifindex);
+			changed_iface = 1;
+		}
 		hai->primary_coa.iif = coa->ifindex;
 		ipv6_addr_copy(&hai->primary_coa.addr, &coa->addr);
 		mn_update_coa_lifetime(&hai->primary_coa, coa);
@@ -2126,9 +2159,15 @@
 			} else if (hai->home_reg_status != HOME_REG_NONE || 
 				   move_home) {
 				mn_do_dad(hai);
-			}
+			} else if(changed_iface) {
+				/* RK - If previous tests failed, but if multiple interfaces are
+				 * in the home network, this allows to allocate the HoA to 
+				 * the correct interface 
+				 */
+				mn_move(hai);
+			}	   
 		}
-	}
+	}		
 }
 
 int mn_movement_event(struct movement_event *event)
diff -Nur NEPL-SE-1.0/src/movement.c NEPL-SE-1.1/src/movement.c
--- NEPL-SE-1.0/src/movement.c	2005-11-01 01:13:14.000000000 +0900
+++ NEPL-SE-1.1/src/movement.c	2005-11-18 16:23:10.000000000 +0900
@@ -296,6 +296,46 @@
 	list_add_tail(&old->list, &iface->expired_rtrs);
 }
 
+/* RK - delete the route associated to the router rtr
+ */
+void md_delete_rtr_routes(struct md_router *rtr)
+{
+	struct list_head *plist;
+	
+	MDBG("deleting default route via %x:%x:%x:%x:%x:%x:%x:%x\n", 
+		NIP6ADDR(&rtr->lladdr));
+	route_del(rtr->ifindex, RT_TABLE_MAIN, 0,
+			&in6addr_any, 0, &in6addr_any, 0, &rtr->lladdr);
+
+	list_for_each(plist, &rtr->prefixes) {
+		struct prefix_list_entry *p;
+		p = list_entry(plist, struct prefix_list_entry, list);
+
+		MDBG2("deleting prefix route %x:%x:%x:%x:%x:%x:%x:%x/%d\n", 
+			NIP6ADDR(&p->ple_prefix), p->ple_plen);
+		route_del(rtr->ifindex, RT_TABLE_MAIN, 0, &in6addr_any,
+				0, &p->ple_prefix, p->ple_plen, NULL);
+	}
+}
+
+/* RK - delete all routes associated to an interface
+ */
+void md_delete_all_routes(struct md_inet6_iface *iface)
+{
+	struct md_router *rtr;
+	struct list_head *rlist;
+
+	list_for_each(rlist, &iface->default_rtr) {
+		rtr = list_entry(rlist, struct md_router, list);
+		md_delete_rtr_routes(rtr);
+	}
+	
+	list_for_each(rlist, &iface->expired_rtrs) {
+		rtr = list_entry(rlist, struct md_router, list);
+		md_delete_rtr_routes(rtr);
+	}
+}
+
 static void md_delete_expired_coas(struct md_inet6_iface *iface)
 {
 	struct list_head *list;
@@ -358,6 +398,8 @@
 		struct md_coa *coa = list_entry(list, struct md_coa, list);
 		md_expire_coa(iface, coa);
 	}
+	/* RK - We delete all routes on this interface */
+	md_delete_all_routes(iface);
 	__md_trigger_movement_event(ME_LINK_DOWN, 0, iface, NULL);
 }
 
diff -Nur NEPL-SE-1.0/src/movement.h NEPL-SE-1.1/src/movement.h
--- NEPL-SE-1.0/src/movement.h	2005-11-01 01:13:14.000000000 +0900
+++ NEPL-SE-1.1/src/movement.h	2005-11-18 16:20:08.000000000 +0900
@@ -176,6 +176,8 @@
 	return NULL;
 }
 
+void md_delete_all_routes(struct md_inet6_iface *iface);
+
 int md_init(void);
 void md_cleanup(void);
 
diff -Nur NEPL-SE-1.0/src/policy.c NEPL-SE-1.1/src/policy.c
--- NEPL-SE-1.0/src/policy.c	2005-11-01 19:31:05.000000000 +0900
+++ NEPL-SE-1.1/src/policy.c	2005-11-18 18:57:36.365501752 +0900
@@ -73,16 +73,34 @@
 {
 	struct md_inet6_iface *best_iface = NULL;
 	struct list_head *list;
+	int at_home = 0, best_iface_home = 0;
 	list_for_each(list, iface_list) {
 		struct md_inet6_iface *iface;
+		struct md_router * rtr;
 		iface = list_entry(list, struct md_inet6_iface, list);
+		rtr = md_get_first_router(&iface->default_rtr);
+		
+		if(rtr != NULL && 
+		   prefix_list_find(&rtr->prefixes, &hai->home_prefix, hai->home_plen)){
+			at_home = 1;
+		} else {
+			at_home = 0;
+		}		
+		
+		/* RK - Algorithm is changed to take into account that the interface 
+		 * at home might be prefered to the one in foreign netowrk
+		 */
 		if (!list_empty(&iface->coas) && 
 		    !list_empty(&iface->default_rtr) &&
 		    (best_iface == NULL || 
-		     best_iface->preference > iface->preference ||
-		     (best_iface->preference == iface->preference &&
+		    (conf.MnPreferHome && at_home &&
+		     !(best_iface_home && best_iface->preference < iface->preference))||
+		    (!conf.MnPreferHome && best_iface->preference > iface->preference)||
+		    (!conf.MnPreferHome && best_iface->preference == iface->preference &&
 		     iface == pref_iface))) {
 			best_iface = iface;
+			if(at_home)
+				best_iface_home = 1;
 		}
 	}
 	return best_iface;
@@ -206,8 +224,16 @@
 	new_iface = policy_best_iface(hai, me->iface, me->iface_list);
 	if (new_iface == NULL)
 		return POLICY_HO_INVALIDATE;
-	if (new_iface != old_iface)
+	if (new_iface != old_iface){
 		old_coa = NULL;
+		/* RK - We delete the router routes on the old interface 
+		   [RK-TODO] This is useful when one interface returns home, but 
+		   still some issues
+		
+		 if(old_iface != NULL){
+			md_delete_all_routes(old_iface);
+		}*/
+	}
 	new_coa = policy_best_coa(hai, NULL, &new_iface->coas);
 	if (new_coa == NULL)
 		return POLICY_HO_INVALIDATE;
diff -Nur NEPL-SE-1.0/src/scan.l NEPL-SE-1.1/src/scan.l
--- NEPL-SE-1.0/src/scan.l	2005-11-01 19:33:07.000000000 +0900
+++ NEPL-SE-1.1/src/scan.l	2005-11-18 12:41:09.000000000 +0900
@@ -132,6 +132,7 @@
 IsRouter			{ return ISROUTER; }
 MnIfPreference			{ return MNIFPREFERENCE; }
 MnUseAllInterfaces     		{ return MNUSEALLINTERFACES; }
+MnPreferHome     		{ return MNPREFERHOME; }
 MnRouterProbesRA		{ return MNROUTERPROBESRA; }
 MnRouterProbesLinkUp		{ return MNROUTERPROBESLINKUP; }
 MnRouterProbeTimeout		{ return MNROUTERPROBETIMEOUT; }
diff -Nur NEPL-SE-1.0/src/tunnelctl.c NEPL-SE-1.1/src/tunnelctl.c
--- NEPL-SE-1.0/src/tunnelctl.c	2005-11-01 01:13:14.000000000 +0900
+++ NEPL-SE-1.1/src/tunnelctl.c	2005-11-09 18:14:40.000000000 +0900
@@ -215,7 +215,8 @@
 	return res;
 }
 
-static struct mip6_tnl *__tunnel_add(struct in6_addr *local,
+static struct mip6_tnl *__tunnel_add(int local_ifindex, 
+				     struct in6_addr *local,
 				     struct in6_addr *remote)
 {
 	struct mip6_tnl *tnl = NULL;
@@ -230,6 +231,7 @@
 	tnl->parm.proto = IPPROTO_IPV6;
 	tnl->parm.flags = IP6_TNL_F_MIP6_DEV|IP6_TNL_F_IGN_ENCAP_LIMIT;
 	tnl->parm.hop_limit = 64;
+	tnl->parm.link = local_ifindex;
 	ipv6_addr_copy(&tnl->parm.laddr, local);
 	ipv6_addr_copy(&tnl->parm.raddr, remote);
 
@@ -294,7 +296,8 @@
  * interface index of the newly created tunnel, or negative on error.
  **/
 /*# TEST */
-int tunnel_add(struct in6_addr *local,
+int tunnel_add(int local_ifindex, 
+	       struct in6_addr *local,
 	       struct in6_addr *remote,
 	       int (*ext_tunnel_ops)(int request, 
 				     int old_if, 
@@ -313,7 +316,7 @@
 		     tnl->parm.name, tnl->ifindex, 
 		     NIP6ADDR(local), NIP6ADDR(remote), tnl->users);
 	} else {
-		if ((tnl = __tunnel_add(local, remote)) == NULL) {
+		if ((tnl = __tunnel_add(local_ifindex, local, remote)) == NULL) {
 			TDBG("failed to create tunnel "
 			     "from %x:%x:%x:%x:%x:%x:%x:%x "
 			     "to %x:%x:%x:%x:%x:%x:%x:%x\n",
@@ -335,6 +338,7 @@
 }
 
 static int __tunnel_mod(struct mip6_tnl *tnl,
+			int local_ifindex,
 			struct in6_addr *local,
 			struct in6_addr *remote)
 {
@@ -347,6 +351,7 @@
 	parm.proto = IPPROTO_IPV6;
 	parm.flags = IP6_TNL_F_MIP6_DEV|IP6_TNL_F_IGN_ENCAP_LIMIT;
 	parm.hop_limit = 64;
+	parm.link = local_ifindex;
 	ipv6_addr_copy(&parm.laddr, local);
 	ipv6_addr_copy(&parm.raddr, remote);
 	
@@ -389,7 +394,8 @@
  * success.
  **/
 /*# TEST */
-int tunnel_mod(int ifindex,
+int tunnel_mod(int ifindex, 
+	       int local_ifindex,
 	       struct in6_addr *local,
 	       struct in6_addr *remote,
 	       int (*ext_tunnel_ops)(int request, 
@@ -424,8 +430,8 @@
 		new = old;
 
 		if (old->users == 1 &&
-		    (res = __tunnel_mod(old, local, remote)) < 0 &&
-		    (new = __tunnel_add(local, remote)) == NULL) {
+		    (res = __tunnel_mod(old, local_ifindex, local, remote)) < 0 &&
+		    (new = __tunnel_add(local_ifindex, local, remote)) == NULL) {
 			_pthread_mutex_unlock(&tnl_lock);
 			return -1;
 		}
diff -Nur NEPL-SE-1.0/src/tunnelctl.h NEPL-SE-1.1/src/tunnelctl.h
--- NEPL-SE-1.0/src/tunnelctl.h	2005-11-01 01:13:14.000000000 +0900
+++ NEPL-SE-1.1/src/tunnelctl.h	2005-11-09 18:15:02.000000000 +0900
@@ -2,7 +2,8 @@
 #ifndef __TUNNELCTL_H__
 #define __TUNNELCTL_H__ 1
 
-int tunnel_add(struct in6_addr *local,
+int tunnel_add(int local_ifindex, 
+	       struct in6_addr *local,
 	       struct in6_addr *remote,
 	       int (*ext_tunnel_ops)(int request, 
 				     int old_if, 
@@ -11,6 +12,7 @@
 	       void *data);
 
 int tunnel_mod(int ifindex,
+	       int local_ifindex,
 	       struct in6_addr *local,
 	       struct in6_addr *remote,
 	       int (*ext_tunnel_ops)(int request, 
