ip: xfrm: Fix policy and state flags.
Subsystems (2)
PATCH 2/3 ip: xfrm: Fix policy and state flags.
o Support policy flag with string format.
Note that kernel defines only one name "localok" for the flag and it has not had any effect currently.
o Support state flag value XFRM_STATE_NOPMTUDISC.
o Fix to show detailed flags value when "-s" option is used.
o Fix minor typo.
Signed-off-by Masahide NAKAMURA <[email protected]>
--- ip/ipxfrm.c | 18 +++++++++++++--- ip/xfrm.h | 1 + ip/xfrm_policy.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++- ip/xfrm_state.c | 6 +++- 4 files changed, 72 insertions(+), 8 deletions(-)
ip/ipxfrm.c +14 -4
@@ -745,12 +745,13 @@ void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,fprintf (fp,"flag " );XFRM_FLAG_PRINT (fp, flags,XFRM_STATE_NOECN ,"noecn" );XFRM_FLAG_PRINT (fp, flags,XFRM_STATE_DECAP_DSCP ,"decap-dscp" ); +XFRM_FLAG_PRINT (fp, flags,XFRM_STATE_NOPMTUDISC ,"nopmtudisc" );XFRM_FLAG_PRINT (fp, flags,XFRM_STATE_WILDRECV ,"wildrecv" );if (flags)fprintf (fp,"%x" , flags); -if (show_stats >0 ) -fprintf (fp," (0x%s)" ,strxf_mask8 (flags)); } +if (show_stats >0 ) +fprintf (fp," (0x%s)" ,strxf_mask8 (xsinfo->flags));fprintf (fp,"%s" , _SL_);xfrm_xfrma_print (tb, xsinfo->family, fp, buf);
@@ -845,10 +846,19 @@ void xfrm_policy_info_print(struct xfrm_userpolicy_info *xpinfo, }fprintf (fp," " ); -if (show_stats >0 ) { +if (show_stats >0 )fprintf (fp,"share %s " ,strxf_share (xpinfo->share)); -fprintf (fp,"flag 0x%s" ,strxf_mask8 (xpinfo->flags)); + +if (show_stats >0 || xpinfo->flags) { +__u8 flags = xpinfo->flags; + +fprintf (fp,"flag " ); +XFRM_FLAG_PRINT (fp, flags,XFRM_POLICY_LOCALOK ,"localok" ); +if (flags) +fprintf (fp,"%x" , flags); } +if (show_stats >0 ) +fprintf (fp," (0x%s)" ,strxf_mask8 (xpinfo->flags));fprintf (fp,"%s" , _SL_);if (show_stats >0 )
ip/xfrm.h +1 -0
@@ -98,6 +98,7 @@ struct xfrm_filter {__u32 index_mask;__u8 action_mask;__u32 priority_mask; +__u8 policy_flags_mask;__u8 ptype;__u8 ptype_mask;
ip/xfrm_policy.c +53 -2
93 lines not on this page · raw message
ip/xfrm_state.c +4 -2
@@ -62,7 +62,7 @@ static void usage(void)fprintf (stderr," [ min SPI max SPI ]\n" );fprintf (stderr,"Usage: ip xfrm state { delete | get } ID\n" );fprintf (stderr,"Usage: ip xfrm state { deleteall | list } [ ID ] [ mode MODE ] [ reqid REQID ]\n" ); -fprintf (stderr," [ flag FLAG_LIST ]\n" ); +fprintf (stderr," [ flag FLAG-LIST ]\n" );fprintf (stderr,"Usage: ip xfrm state flush [ proto XFRM_PROTO ]\n" );fprintf (stderr,"Usage: ip xfrm state count \n" );
@@ -82,7 +82,7 @@ static void usage(void)//fprintf(stderr, "REQID - number(default=0)\n"); fprintf (stderr,"FLAG-LIST := [ FLAG-LIST ] FLAG\n" ); -fprintf (stderr,"FLAG := [ noecn | decap-dscp | wildrecv ]\n" ); +fprintf (stderr,"FLAG := [ noecn | decap-dscp | nopmtudisc | wildrecv ]\n" );fprintf (stderr,"ENCAP := ENCAP-TYPE SPORT DPORT OADDR\n" );fprintf (stderr,"ENCAP-TYPE := espinudp | espinudp-nonike\n" );
@@ -203,6 +203,8 @@ static int xfrm_state_flag_parse(__u8 *flags, int *argcp, char ***argvp) *flags |=XFRM_STATE_NOECN ; else if (strcmp(*argv, "decap-dscp") == 0) *flags |=XFRM_STATE_DECAP_DSCP ; + else if (strcmp(*argv, "nopmtudisc") == 0) + *flags |= XFRM_STATE_NOPMTUDISC; else if (strcmp(*argv, "wildrecv") == 0) *flags |= XFRM_STATE_WILDRECV; else {
Signature · 1 line
1.4.4.2