@@ -1187,24 +1187,6 @@ __xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir
1187
1187
return xfrm_policy_lookup_bytype (net , XFRM_POLICY_TYPE_MAIN , fl , family , dir );
1188
1188
}
1189
1189
1190
- static int flow_to_policy_dir (int dir )
1191
- {
1192
- if (XFRM_POLICY_IN == FLOW_DIR_IN &&
1193
- XFRM_POLICY_OUT == FLOW_DIR_OUT &&
1194
- XFRM_POLICY_FWD == FLOW_DIR_FWD )
1195
- return dir ;
1196
-
1197
- switch (dir ) {
1198
- default :
1199
- case FLOW_DIR_IN :
1200
- return XFRM_POLICY_IN ;
1201
- case FLOW_DIR_OUT :
1202
- return XFRM_POLICY_OUT ;
1203
- case FLOW_DIR_FWD :
1204
- return XFRM_POLICY_FWD ;
1205
- }
1206
- }
1207
-
1208
1190
static struct flow_cache_object *
1209
1191
xfrm_policy_lookup (struct net * net , const struct flowi * fl , u16 family ,
1210
1192
u8 dir , struct flow_cache_object * old_obj , void * ctx )
@@ -1214,7 +1196,7 @@ xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family,
1214
1196
if (old_obj )
1215
1197
xfrm_pol_put (container_of (old_obj , struct xfrm_policy , flo ));
1216
1198
1217
- pol = __xfrm_policy_lookup (net , fl , family , flow_to_policy_dir ( dir ) );
1199
+ pol = __xfrm_policy_lookup (net , fl , family , dir );
1218
1200
if (IS_ERR_OR_NULL (pol ))
1219
1201
return ERR_CAST (pol );
1220
1202
@@ -1225,23 +1207,6 @@ xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family,
1225
1207
return & pol -> flo ;
1226
1208
}
1227
1209
1228
- static inline int policy_to_flow_dir (int dir )
1229
- {
1230
- if (XFRM_POLICY_IN == FLOW_DIR_IN &&
1231
- XFRM_POLICY_OUT == FLOW_DIR_OUT &&
1232
- XFRM_POLICY_FWD == FLOW_DIR_FWD )
1233
- return dir ;
1234
- switch (dir ) {
1235
- default :
1236
- case XFRM_POLICY_IN :
1237
- return FLOW_DIR_IN ;
1238
- case XFRM_POLICY_OUT :
1239
- return FLOW_DIR_OUT ;
1240
- case XFRM_POLICY_FWD :
1241
- return FLOW_DIR_FWD ;
1242
- }
1243
- }
1244
-
1245
1210
static struct xfrm_policy * xfrm_sk_policy_lookup (const struct sock * sk , int dir ,
1246
1211
const struct flowi * fl , u16 family )
1247
1212
{
@@ -1261,7 +1226,7 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
1261
1226
}
1262
1227
err = security_xfrm_policy_lookup (pol -> security ,
1263
1228
fl -> flowi_secid ,
1264
- policy_to_flow_dir ( dir ) );
1229
+ dir );
1265
1230
if (!err ) {
1266
1231
if (!xfrm_pol_hold_rcu (pol ))
1267
1232
goto again ;
@@ -2063,8 +2028,7 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
2063
2028
/* Resolve policies to use if we couldn't get them from
2064
2029
* previous cache entry */
2065
2030
num_pols = 1 ;
2066
- pols [0 ] = __xfrm_policy_lookup (net , fl , family ,
2067
- flow_to_policy_dir (dir ));
2031
+ pols [0 ] = __xfrm_policy_lookup (net , fl , family , dir );
2068
2032
err = xfrm_expand_policies (fl , family , pols ,
2069
2033
& num_pols , & num_xfrms );
2070
2034
if (err < 0 )
@@ -2142,7 +2106,7 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
2142
2106
struct xfrm_dst * xdst ;
2143
2107
struct dst_entry * dst , * route ;
2144
2108
u16 family = dst_orig -> ops -> family ;
2145
- u8 dir = policy_to_flow_dir ( XFRM_POLICY_OUT ) ;
2109
+ u8 dir = XFRM_POLICY_OUT ;
2146
2110
int i , err , num_pols , num_xfrms = 0 , drop_pols = 0 ;
2147
2111
2148
2112
dst = NULL ;
@@ -2399,12 +2363,10 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
2399
2363
int pi ;
2400
2364
int reverse ;
2401
2365
struct flowi fl ;
2402
- u8 fl_dir ;
2403
2366
int xerr_idx = -1 ;
2404
2367
2405
2368
reverse = dir & ~XFRM_POLICY_MASK ;
2406
2369
dir &= XFRM_POLICY_MASK ;
2407
- fl_dir = policy_to_flow_dir (dir );
2408
2370
2409
2371
if (__xfrm_decode_session (skb , & fl , family , reverse ) < 0 ) {
2410
2372
XFRM_INC_STATS (net , LINUX_MIB_XFRMINHDRERROR );
0 commit comments