<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 4 Sep 2019 at 10:40, Paul Wouters <<a href="mailto:paul@nohats.ca">paul@nohats.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">><br>
><br>
>  New commits:<br>
>  commit 4972d0201f054b6c5de8804a20fc56679a72c8bd<br>
>  Author: Andrew Cagney <<a href="mailto:cagney@gnu.org" target="_blank">cagney@gnu.org</a>><br>
>  Date:   Wed Sep 4 09:50:35 2019 -0400<br>
><br>
>      ip: add jam_subnet_port() <a href="http://et.al" rel="noreferrer" target="_blank">et.al</a>., test<br>
><br>
>      Note the long standing bug: because the port is stored as a uint16_t<br>
>      in a sockaddr(1), it isn't possible to differentiate between no-port<br>
>      and zero port.  Since this is going to replace:<br>
><br>
>          "%s:%d", str_subnet(), subnet_hport()<br>
><br>
>      it mimics that behaviour, at least for now (don't be fooled by the<br>
>      preemptive hport<0 check).<br>
<br>
Using 0 for protocols or ports always means "all of it" in IKE/IPsec and<br>
never means "none". So this is not a bug that needs fixing.<br></blockquote><div><br></div><div>Our code isn't so sure:</div><div><br></div><div>        /*<br>         * if port is %any or 0 we mean all ports (or all iccmp/icmpv6)<br>         * See RFC-5996 Section 3.13.1 handling for ICMP(1) and ICMPv6(58)<br>         *   we only support providing Type, not Code, eg protoport=1/1<br>         */<br>        if (e->port == 0 || e->has_port_wildcard) {<br>                ts.startport = 0;<br>                ts.endport = 65535;<br></div><div><br></div><div>so while port 0 is a real bad idea, and should indicate "all", we'd be on safer ground if ip_subnet used something unambiguous to indicate "all ports".  For instance a port outside of the range 0..65535, or a separate bool.</div><div><br></div><div><a href="http://google.com:0/">http://google.com:0/</a> anyone?</div><div><a href="https://daniel.haxx.se/blog/2014/10/25/pretending-port-zero-is-a-normal-one/">https://daniel.haxx.se/blog/2014/10/25/pretending-port-zero-is-a-normal-one/</a></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br></blockquote></div></div>