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]
Date:	Mon, 3 Jun 2013 16:02:59 +0900
From:	Lorenzo Colitti <lorenzo@...gle.com>
To:	Cong Wang <amwang@...hat.com>
Cc:	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [Patch net-next 1/2] ping: some cleanup for net/ipv4/ping.c

On Mon, Jun 3, 2013 at 2:55 PM, Cong Wang <amwang@...hat.com> wrote:
> -static inline int ping_supported(int family, int type, int code)
> +static inline bool ping_supported(int family, int type, int code)
>  {
> -       return (family == AF_INET && type == ICMP_ECHO && code == 0) ||
> -              (family == AF_INET6 && type == ICMPV6_ECHO_REQUEST && code == 0);
> +       if (family == AF_INET) {
> +               if (type == ICMP_ECHO && code == 0)
> +                       return true;
> +#if IS_ENABLED(CONFIG_IPV6)
> +       } else if (family == AF_INET6) {
> +               if (type == ICMPV6_ECHO_REQUEST && code == 0)
> +                       return true;
> +#endif
> +       }
> +       return false;
>  }

I don't think it's necessary to #ifdef out code here. It's not needed
to get the code to compile, because AF_INET6 and ICMPV6_ECHO_REQUEST
are defined even if CONFIG_IPV6=n. It's also not necessary at runtime,
because if we get here with family = AF_INET6 even though IPv6 is
disabled, then then there's already a problem. Adding the ifdef also
makes the function much hard to read.

>
>  /*
> @@ -472,11 +480,13 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
>                 type = icmp_hdr(skb)->type;
>                 code = icmp_hdr(skb)->code;
>                 icmph = (struct icmphdr *)(skb->data + offset);
> +#if IS_ENABLED(CONFIG_IPV6)
>         } else if (skb->protocol == htons(ETH_P_IPV6)) {
>                 family = AF_INET6;
>                 type = icmp6_hdr(skb)->icmp6_type;
>                 code = icmp6_hdr(skb)->icmp6_code;
>                 icmph = (struct icmphdr *) (skb->data + offset);
> +#endif
>         } else {
>                 BUG();
>         }

I think this is unnecessary too. ping_err is only called by icmp_err
and by icmpv6_err, and if icmp_err is calling us on an IPv4 packet, or
if icmpv6_err is calling us when IPv6 is unloaded, then there are
bigger problems.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ