ip-xfrm: Respect family in deleteall and list commands
Allow to limit 'ip xfrm {state|policy} list' output to a certain address
family and to delete all states/policies by family.
Although preferred_family was already set in filters, the filter
function ignored it. To enable filtering despite the lack of other
selectors, filter.use has to be set if family is not AF_UNSPEC.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
9bf2c538a0
commit
cd21ae4013
|
|
@ -410,6 +410,10 @@ static int xfrm_policy_filter_match(struct xfrm_userpolicy_info *xpinfo,
|
||||||
if (!filter.use)
|
if (!filter.use)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (filter.xpinfo.sel.family != AF_UNSPEC &&
|
||||||
|
filter.xpinfo.sel.family != xpinfo->sel.family)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ((xpinfo->dir^filter.xpinfo.dir)&filter.dir_mask)
|
if ((xpinfo->dir^filter.xpinfo.dir)&filter.dir_mask)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
@ -780,7 +784,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
|
||||||
char *selp = NULL;
|
char *selp = NULL;
|
||||||
struct rtnl_handle rth;
|
struct rtnl_handle rth;
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0 || preferred_family != AF_UNSPEC)
|
||||||
filter.use = 1;
|
filter.use = 1;
|
||||||
filter.xpinfo.sel.family = preferred_family;
|
filter.xpinfo.sel.family = preferred_family;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -898,6 +898,10 @@ static int xfrm_state_filter_match(struct xfrm_usersa_info *xsinfo)
|
||||||
if (!filter.use)
|
if (!filter.use)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (filter.xsinfo.family != AF_UNSPEC &&
|
||||||
|
filter.xsinfo.family != xsinfo->family)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (filter.id_src_mask)
|
if (filter.id_src_mask)
|
||||||
if (xfrm_addr_match(&xsinfo->saddr, &filter.xsinfo.saddr,
|
if (xfrm_addr_match(&xsinfo->saddr, &filter.xsinfo.saddr,
|
||||||
filter.id_src_mask))
|
filter.id_src_mask))
|
||||||
|
|
@ -1170,7 +1174,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
|
||||||
struct rtnl_handle rth;
|
struct rtnl_handle rth;
|
||||||
bool nokeys = false;
|
bool nokeys = false;
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0 || preferred_family != AF_UNSPEC)
|
||||||
filter.use = 1;
|
filter.use = 1;
|
||||||
filter.xsinfo.family = preferred_family;
|
filter.xsinfo.family = preferred_family;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ ip-xfrm \- transform configuration
|
||||||
.IR MASK " ] ]"
|
.IR MASK " ] ]"
|
||||||
|
|
||||||
.ti -8
|
.ti -8
|
||||||
.BR "ip xfrm state " deleteall " ["
|
.BR ip " [ " -4 " | " -6 " ] " "xfrm state deleteall" " ["
|
||||||
.IR ID " ]"
|
.IR ID " ]"
|
||||||
.RB "[ " mode
|
.RB "[ " mode
|
||||||
.IR MODE " ]"
|
.IR MODE " ]"
|
||||||
|
|
@ -99,7 +99,7 @@ ip-xfrm \- transform configuration
|
||||||
.IR FLAG-LIST " ]"
|
.IR FLAG-LIST " ]"
|
||||||
|
|
||||||
.ti -8
|
.ti -8
|
||||||
.BR "ip xfrm state " list " ["
|
.BR ip " [ " -4 " | " -6 " ] " "xfrm state list" " ["
|
||||||
.IR ID " ]"
|
.IR ID " ]"
|
||||||
.RB "[ " nokeys " ]"
|
.RB "[ " nokeys " ]"
|
||||||
.RB "[ " mode
|
.RB "[ " mode
|
||||||
|
|
@ -257,7 +257,7 @@ ip-xfrm \- transform configuration
|
||||||
.IR PTYPE " ]"
|
.IR PTYPE " ]"
|
||||||
|
|
||||||
.ti -8
|
.ti -8
|
||||||
.BR "ip xfrm policy" " { " deleteall " | " list " }"
|
.BR ip " [ " -4 " | " -6 " ] " "xfrm policy" " { " deleteall " | " list " }"
|
||||||
.RB "[ " nosock " ]"
|
.RB "[ " nosock " ]"
|
||||||
.RI "[ " SELECTOR " ]"
|
.RI "[ " SELECTOR " ]"
|
||||||
.RB "[ " dir
|
.RB "[ " dir
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue