@@ -941,6 +941,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
941941 int error = 0 ;
942942 struct xfrm_state * best = NULL ;
943943 u32 mark = pol -> mark .v & pol -> mark .m ;
944+ u32 if_id = fl -> flowi_xfrm .if_id ;
944945 unsigned short encap_family = tmpl -> encap_family ;
945946 unsigned int sequence ;
946947 struct km_event c ;
@@ -955,6 +956,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
955956 if (x -> props .family == encap_family &&
956957 x -> props .reqid == tmpl -> reqid &&
957958 (mark & x -> mark .m ) == x -> mark .v &&
959+ x -> if_id == if_id &&
958960 !(x -> props .flags & XFRM_STATE_WILDRECV ) &&
959961 xfrm_state_addr_check (x , daddr , saddr , encap_family ) &&
960962 tmpl -> mode == x -> props .mode &&
@@ -971,6 +973,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
971973 if (x -> props .family == encap_family &&
972974 x -> props .reqid == tmpl -> reqid &&
973975 (mark & x -> mark .m ) == x -> mark .v &&
976+ x -> if_id == if_id &&
974977 !(x -> props .flags & XFRM_STATE_WILDRECV ) &&
975978 xfrm_addr_equal (& x -> id .daddr , daddr , encap_family ) &&
976979 tmpl -> mode == x -> props .mode &&
@@ -1010,6 +1013,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
10101013 * to current session. */
10111014 xfrm_init_tempstate (x , fl , tmpl , daddr , saddr , family );
10121015 memcpy (& x -> mark , & pol -> mark , sizeof (x -> mark ));
1016+ x -> if_id = if_id ;
10131017
10141018 error = security_xfrm_state_alloc_acquire (x , pol -> security , fl -> flowi_secid );
10151019 if (error ) {
@@ -1067,7 +1071,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
10671071}
10681072
10691073struct xfrm_state *
1070- xfrm_stateonly_find (struct net * net , u32 mark ,
1074+ xfrm_stateonly_find (struct net * net , u32 mark , u32 if_id ,
10711075 xfrm_address_t * daddr , xfrm_address_t * saddr ,
10721076 unsigned short family , u8 mode , u8 proto , u32 reqid )
10731077{
@@ -1080,6 +1084,7 @@ xfrm_stateonly_find(struct net *net, u32 mark,
10801084 if (x -> props .family == family &&
10811085 x -> props .reqid == reqid &&
10821086 (mark & x -> mark .m ) == x -> mark .v &&
1087+ x -> if_id == if_id &&
10831088 !(x -> props .flags & XFRM_STATE_WILDRECV ) &&
10841089 xfrm_state_addr_check (x , daddr , saddr , family ) &&
10851090 mode == x -> props .mode &&
@@ -1160,11 +1165,13 @@ static void __xfrm_state_bump_genids(struct xfrm_state *xnew)
11601165 struct xfrm_state * x ;
11611166 unsigned int h ;
11621167 u32 mark = xnew -> mark .v & xnew -> mark .m ;
1168+ u32 if_id = xnew -> if_id ;
11631169
11641170 h = xfrm_dst_hash (net , & xnew -> id .daddr , & xnew -> props .saddr , reqid , family );
11651171 hlist_for_each_entry (x , net -> xfrm .state_bydst + h , bydst ) {
11661172 if (x -> props .family == family &&
11671173 x -> props .reqid == reqid &&
1174+ x -> if_id == if_id &&
11681175 (mark & x -> mark .m ) == x -> mark .v &&
11691176 xfrm_addr_equal (& x -> id .daddr , & xnew -> id .daddr , family ) &&
11701177 xfrm_addr_equal (& x -> props .saddr , & xnew -> props .saddr , family ))
@@ -1187,7 +1194,7 @@ EXPORT_SYMBOL(xfrm_state_insert);
11871194static struct xfrm_state * __find_acq_core (struct net * net ,
11881195 const struct xfrm_mark * m ,
11891196 unsigned short family , u8 mode ,
1190- u32 reqid , u8 proto ,
1197+ u32 reqid , u32 if_id , u8 proto ,
11911198 const xfrm_address_t * daddr ,
11921199 const xfrm_address_t * saddr ,
11931200 int create )
@@ -1242,6 +1249,7 @@ static struct xfrm_state *__find_acq_core(struct net *net,
12421249 x -> props .family = family ;
12431250 x -> props .mode = mode ;
12441251 x -> props .reqid = reqid ;
1252+ x -> if_id = if_id ;
12451253 x -> mark .v = m -> v ;
12461254 x -> mark .m = m -> m ;
12471255 x -> lft .hard_add_expires_seconds = net -> xfrm .sysctl_acq_expires ;
@@ -1296,7 +1304,7 @@ int xfrm_state_add(struct xfrm_state *x)
12961304
12971305 if (use_spi && !x1 )
12981306 x1 = __find_acq_core (net , & x -> mark , family , x -> props .mode ,
1299- x -> props .reqid , x -> id .proto ,
1307+ x -> props .reqid , x -> if_id , x -> id .proto ,
13001308 & x -> id .daddr , & x -> props .saddr , 0 );
13011309
13021310 __xfrm_state_bump_genids (x );
@@ -1395,6 +1403,7 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,
13951403 x -> props .flags = orig -> props .flags ;
13961404 x -> props .extra_flags = orig -> props .extra_flags ;
13971405
1406+ x -> if_id = orig -> if_id ;
13981407 x -> tfcpad = orig -> tfcpad ;
13991408 x -> replay_maxdiff = orig -> replay_maxdiff ;
14001409 x -> replay_maxage = orig -> replay_maxage ;
@@ -1619,13 +1628,13 @@ EXPORT_SYMBOL(xfrm_state_lookup_byaddr);
16191628
16201629struct xfrm_state *
16211630xfrm_find_acq (struct net * net , const struct xfrm_mark * mark , u8 mode , u32 reqid ,
1622- u8 proto , const xfrm_address_t * daddr ,
1631+ u32 if_id , u8 proto , const xfrm_address_t * daddr ,
16231632 const xfrm_address_t * saddr , int create , unsigned short family )
16241633{
16251634 struct xfrm_state * x ;
16261635
16271636 spin_lock_bh (& net -> xfrm .xfrm_state_lock );
1628- x = __find_acq_core (net , mark , family , mode , reqid , proto , daddr , saddr , create );
1637+ x = __find_acq_core (net , mark , family , mode , reqid , if_id , proto , daddr , saddr , create );
16291638 spin_unlock_bh (& net -> xfrm .xfrm_state_lock );
16301639
16311640 return x ;
0 commit comments