ip rule: suppress routes based on ifgroup
Subsystems (2)
PATCH v2 2/2 ip rule: suppress routes based on ifgroup
Signed-off-by Stefan Tomanek <[email protected]>
--- include/linux/fib_rules.h | 2 +- ip/iprule.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
include/linux/fib_rules.h +1 -1
@@ -44,7 +44,7 @@ enum {FRA_FWMARK ,/* mark */ FRA_FLOW ,/* flow/class id */ FRA_UNUSED6 , -FRA_UNUSED7 , +FRA_SUPPRESS_IFGROUP ,FRA_TABLE_PREFIXLEN_MIN ,FRA_TABLE ,/* Extended table id */ FRA_FWMASK, /* mask for netfilter mark */
ip/iprule.c +13 -0
@@ -41,6 +41,7 @@ static void usage(void)fprintf (stderr," [ goto NUMBER ]\n" );fprintf (stderr," SUPPRESSOR\n" );fprintf (stderr,"SUPPRESSOR := [ prefixlength NUMBER ]\n" ); +fprintf (stderr," [ suppress_group DEVGROUP ]\n" );fprintf (stderr,"TABLE_ID := [ local | main | default | NUMBER ]\n" );exit (-1 ); }
@@ -163,6 +164,12 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)fprintf (fp,"prefixlength %u " , pl); } } +if (tb[FRA_SUPPRESS_IFGROUP ]) { +int group =rta_getattr_u32 (tb[FRA_SUPPRESS_IFGROUP ]); +if (group) { +fprintf (fp,"suppress_ifgroup %d " , group); + } + } }if (tb[FRA_FLOW ]) {__u32 to =rta_getattr_u32 (tb[FRA_FLOW ]);
@@ -325,6 +332,12 @@ static int iprule_modify(int cmd, int argc, char **argv)if (get_u8 (&pl, *argv,0 ))invarg ("prefixlength value is invalid\n" , *argv);addattr8 (&req.n,sizeof (req),FRA_TABLE_PREFIXLEN_MIN , pl); + }else if (matches (*argv,"suppress_group" ) ==0 ) { +NEXT_ARG (); +int group; +if (rtnl_group_a2n (&group, *argv)) +invarg ("Invalid \"suppress_group\" value\n" , *argv); +addattr32 (&req.n,sizeof (req),FRA_SUPPRESS_IFGROUP , group); }else if (strcmp (*argv,"dev" ) ==0 ||strcmp (*argv,"iif" ) ==0 ) {NEXT_ARG ();
Signature · 1 line
1.7.10.4