W
wkevin
Hi all,
I delved into code of net/xfrm/xfrm_policy.c and there is something
which seems quite mysterious to
me . I would appreciate if someone could explain.
I am looking in kernel 2.6.32.11, but this code seems to be from long
ago with no change.
we have, in __xfrm_policy_check(), this msytery:
{
....
int reverse;
....
reverse = dir & ~XFRM_POLICY_MASK;
dir &= XFRM_POLICY_MASK;
....
Now , we have this enum:
enum
{
XFRM_POLICY_IN = 0,
XFRM_POLICY_IN = 1,
XFRM_POLICY_FWD = 2,
XFRM_POLICY_MASK = 3,
XFRM_POLICY_MAX = 3
};
and dir can be XFRM_POLICY_IN or XFRM_POLICY_OUT or XFRM_POLICY_FW.
Now , isn't reverse value is always 0 ?
I tried this short problem covering all three cases:
int main()
{
int reverse;
reverse = XFRM_POLICY_IN & ~XFRM_POLICY_MASK;
printf("XFRM_POLICY_IN & ~XFRM_POLICY_MASK = %d in %s
\n",reverse,__func__);
reverse = XFRM_POLICY_OUT & ~XFRM_POLICY_MASK;
printf("XFRM_POLICY_OUT & ~XFRM_POLICY_MASK = %d in %s
\n",reverse,__func__);
reverse = XFRM_POLICY_FWD & ~XFRM_POLICY_MASK;
printf("XFRM_POLICY_FWD & ~XFRM_POLICY_MASK = %d in %s
\n",reverse,__func__);
}
and it prints 0 in all three cases:
XFRM_POLICY_IN & ~XFRM_POLICY_MASK = 0 in main
XFRM_POLICY_OUT & ~XFRM_POLICY_MASK = 0 in main
XFRM_POLICY_FWD & ~XFRM_POLICY_MASK = 0 in main
so what is the purpose of
reverse = dir & ~XFRM_POLICY_MASK;
why not simply: reverse = XFRM_POLICY_IN
if in all cases it sets reverse to 0 ?
rgs,
Kevin
I delved into code of net/xfrm/xfrm_policy.c and there is something
which seems quite mysterious to
me . I would appreciate if someone could explain.
I am looking in kernel 2.6.32.11, but this code seems to be from long
ago with no change.
we have, in __xfrm_policy_check(), this msytery:
{
....
int reverse;
....
reverse = dir & ~XFRM_POLICY_MASK;
dir &= XFRM_POLICY_MASK;
....
Now , we have this enum:
enum
{
XFRM_POLICY_IN = 0,
XFRM_POLICY_IN = 1,
XFRM_POLICY_FWD = 2,
XFRM_POLICY_MASK = 3,
XFRM_POLICY_MAX = 3
};
and dir can be XFRM_POLICY_IN or XFRM_POLICY_OUT or XFRM_POLICY_FW.
Now , isn't reverse value is always 0 ?
I tried this short problem covering all three cases:
int main()
{
int reverse;
reverse = XFRM_POLICY_IN & ~XFRM_POLICY_MASK;
printf("XFRM_POLICY_IN & ~XFRM_POLICY_MASK = %d in %s
\n",reverse,__func__);
reverse = XFRM_POLICY_OUT & ~XFRM_POLICY_MASK;
printf("XFRM_POLICY_OUT & ~XFRM_POLICY_MASK = %d in %s
\n",reverse,__func__);
reverse = XFRM_POLICY_FWD & ~XFRM_POLICY_MASK;
printf("XFRM_POLICY_FWD & ~XFRM_POLICY_MASK = %d in %s
\n",reverse,__func__);
}
and it prints 0 in all three cases:
XFRM_POLICY_IN & ~XFRM_POLICY_MASK = 0 in main
XFRM_POLICY_OUT & ~XFRM_POLICY_MASK = 0 in main
XFRM_POLICY_FWD & ~XFRM_POLICY_MASK = 0 in main
so what is the purpose of
reverse = dir & ~XFRM_POLICY_MASK;
why not simply: reverse = XFRM_POLICY_IN
if in all cases it sets reverse to 0 ?
rgs,
Kevin