lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52943107-31b3-2515-c64a-f26d66c3c56c@gmail.com>
Date:   Thu, 22 Feb 2018 14:28:48 -0700
From:   David Ahern <dsahern@...il.com>
To:     Donald Sharp <sharpd@...ulusnetworks.com>, netdev@...r.kernel.org
Subject: Re: [PATCH v2 iproute2-next 2/3] ip: Display ip rule protocol used

On 2/21/18 7:12 PM, Donald Sharp wrote:
> diff --git a/ip/iprule.c b/ip/iprule.c
> index 00a6c26a..39008768 100644
> --- a/ip/iprule.c
> +++ b/ip/iprule.c
> @@ -47,6 +47,7 @@ static void usage(void)
>  		"            [ iif STRING ] [ oif STRING ] [ pref NUMBER ] [ l3mdev ]\n"
>  		"            [ uidrange NUMBER-NUMBER ]\n"
>  		"ACTION := [ table TABLE_ID ]\n"
> +		"          [ protocol RPROTO ]\n"

Drop the 'R' makes it harder to read; just 'PROTO' is fine.


>  		"          [ nat ADDRESS ]\n"
>  		"          [ realms [SRCREALM/]DSTREALM ]\n"
>  		"          [ goto NUMBER ]\n"
> @@ -71,6 +72,8 @@ static struct
>  	struct fib_rule_uid_range range;
>  	inet_prefix src;
>  	inet_prefix dst;
> +	int protocol;
> +	int protocolmask;
>  } filter;
>  
>  static inline int frh_get_table(struct fib_rule_hdr *frh, struct rtattr **tb)
> @@ -338,6 +341,10 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
>  			rtnl_rtntype_n2a(frh->action,
>  					 b1, sizeof(b1)));
>  
> +	if (frh->proto != RTPROT_UNSPEC)
> +		fprintf(fp, " proto %s ",
> +			rtnl_rtprot_n2a(frh->proto, b1, sizeof(b1)));
> +
>  	fprintf(fp, "\n");
>  	fflush(fp);
>  	return 0;
> @@ -391,6 +398,9 @@ static int flush_rule(const struct sockaddr_nl *who, struct nlmsghdr *n,
>  
>  	parse_rtattr(tb, FRA_MAX, RTM_RTA(frh), len);
>  
> +	if ((filter.protocol^frh->proto)&filter.protocolmask)
> +		return 0;
> +
>  	if (tb[FRA_PRIORITY]) {
>  		n->nlmsg_type = RTM_DELRULE;
>  		n->nlmsg_flags = NLM_F_REQUEST;
> @@ -415,12 +425,6 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
>  	if (af == AF_UNSPEC)
>  		af = AF_INET;
>  
> -	if (action != IPRULE_LIST && argc > 0) {
> -		fprintf(stderr, "\"ip rule %s\" does not take any arguments.\n",
> -				action == IPRULE_SAVE ? "save" : "flush");
> -		return -1;
> -	}
> -
>  	switch (action) {
>  	case IPRULE_SAVE:
>  		if (save_rule_prep())
> @@ -508,7 +512,18 @@ static int iprule_list_flush_or_save(int argc, char **argv, int action)
>  			NEXT_ARG();
>  			if (get_prefix(&filter.src, *argv, af))
>  				invarg("from value is invalid\n", *argv);
> -		} else {
> +		} else if (matches(*argv, "protocol") == 0) {
> +			__u32 prot;
> +			NEXT_ARG();
> +			filter.protocolmask = -1;
> +			if (rtnl_rtprot_a2n(&prot, *argv)) {
> +				if (strcmp(*argv, "all") != 0)
> +					invarg("invalid \"protocol\"\n", *argv);
> +				prot = 0;
> +				filter.protocolmask = 0;
> +			}
> +			filter.protocol = prot;
> +		} else{
>  			if (matches(*argv, "dst") == 0 ||
>  			    matches(*argv, "to") == 0) {
>  				NEXT_ARG();
> diff --git a/man/man8/ip-rule.8 b/man/man8/ip-rule.8
> index a5c47981..98b2573d 100644
> --- a/man/man8/ip-rule.8
> +++ b/man/man8/ip-rule.8
> @@ -50,6 +50,8 @@ ip-rule \- routing policy database management
>  .IR ACTION " := [ "
>  .B  table
>  .IR TABLE_ID " ] [ "
> +.B  protocol
> +.IR RPROTO " ] [ "

same here and others in this file



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ