Skip to content

Commit aff669b

Browse files
Florian Westphaldavem330
authored andcommitted
xfrm_policy: kill flow to policy dir conversion
XFRM_POLICY_IN/OUT/FWD are identical to FLOW_DIR_*, so gcc already removed this function as its just returns the argument. Again, no code change. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 855dad9 commit aff669b

File tree

1 file changed

+4
-42
lines changed

1 file changed

+4
-42
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,24 +1187,6 @@ __xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir
11871187
return xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family, dir);
11881188
}
11891189

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-
12081190
static struct flow_cache_object *
12091191
xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family,
12101192
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,
12141196
if (old_obj)
12151197
xfrm_pol_put(container_of(old_obj, struct xfrm_policy, flo));
12161198

1217-
pol = __xfrm_policy_lookup(net, fl, family, flow_to_policy_dir(dir));
1199+
pol = __xfrm_policy_lookup(net, fl, family, dir);
12181200
if (IS_ERR_OR_NULL(pol))
12191201
return ERR_CAST(pol);
12201202

@@ -1225,23 +1207,6 @@ xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family,
12251207
return &pol->flo;
12261208
}
12271209

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-
12451210
static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
12461211
const struct flowi *fl, u16 family)
12471212
{
@@ -1261,7 +1226,7 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
12611226
}
12621227
err = security_xfrm_policy_lookup(pol->security,
12631228
fl->flowi_secid,
1264-
policy_to_flow_dir(dir));
1229+
dir);
12651230
if (!err) {
12661231
if (!xfrm_pol_hold_rcu(pol))
12671232
goto again;
@@ -2063,8 +2028,7 @@ xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
20632028
/* Resolve policies to use if we couldn't get them from
20642029
* previous cache entry */
20652030
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);
20682032
err = xfrm_expand_policies(fl, family, pols,
20692033
&num_pols, &num_xfrms);
20702034
if (err < 0)
@@ -2142,7 +2106,7 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
21422106
struct xfrm_dst *xdst;
21432107
struct dst_entry *dst, *route;
21442108
u16 family = dst_orig->ops->family;
2145-
u8 dir = policy_to_flow_dir(XFRM_POLICY_OUT);
2109+
u8 dir = XFRM_POLICY_OUT;
21462110
int i, err, num_pols, num_xfrms = 0, drop_pols = 0;
21472111

21482112
dst = NULL;
@@ -2399,12 +2363,10 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
23992363
int pi;
24002364
int reverse;
24012365
struct flowi fl;
2402-
u8 fl_dir;
24032366
int xerr_idx = -1;
24042367

24052368
reverse = dir & ~XFRM_POLICY_MASK;
24062369
dir &= XFRM_POLICY_MASK;
2407-
fl_dir = policy_to_flow_dir(dir);
24082370

24092371
if (__xfrm_decode_session(skb, &fl, family, reverse) < 0) {
24102372
XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR);

0 commit comments

Comments
 (0)