Richard W.M. Jones
2022-Jan-19 13:46 UTC
[Libguestfs] [nbdkit PATCH 2/2] server/sockets: get rid of AI_ADDRCONFIG
On Tue, Jan 18, 2022 at 11:19:18AM -0600, Eric Blake wrote:> On Tue, Jan 18, 2022 at 02:48:33PM +0100, Laszlo Ersek wrote: > > + case '4': > > + tcpip_sock_af = AF_INET; > > + break; > > + > > + case '6': > > + tcpip_sock_af = AF_INET6; > > + break; > > Thus, if the user uses nbdkit -46 (or -64), the last one specified > silently overrides the earlier one, rather than being diagnosed as > conflicting or explicitly permitting both. The override effect > matches the long-option naming --ipv4-only, so I can live with it, but > I'm also open to the idea of explicitly adding code to diagnose both > options at the same time as an error, if we think that's friendlier > than silent override.Is that actually an error? -4 -6 says you want to listen on IPv4 and IPv6 which is redundant but not wrong. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Richard W.M. Jones
2022-Jan-19 13:47 UTC
[Libguestfs] [nbdkit PATCH 2/2] server/sockets: get rid of AI_ADDRCONFIG
On Wed, Jan 19, 2022 at 01:46:08PM +0000, Richard W.M. Jones wrote:> On Tue, Jan 18, 2022 at 11:19:18AM -0600, Eric Blake wrote: > > On Tue, Jan 18, 2022 at 02:48:33PM +0100, Laszlo Ersek wrote: > > > + case '4': > > > + tcpip_sock_af = AF_INET; > > > + break; > > > + > > > + case '6': > > > + tcpip_sock_af = AF_INET6; > > > + break; > > > > Thus, if the user uses nbdkit -46 (or -64), the last one specified > > silently overrides the earlier one, rather than being diagnosed as > > conflicting or explicitly permitting both. The override effect > > matches the long-option naming --ipv4-only, so I can live with it, but > > I'm also open to the idea of explicitly adding code to diagnose both > > options at the same time as an error, if we think that's friendlier > > than silent override. > > Is that actually an error? -4 -6 says you want to listen on IPv4 and > IPv6 which is redundant but not wrong.Oh wait, actually it doesn't work like I expected. Is it easy to make -4 -6 listen on both IPv4 & IPv6? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Laszlo Ersek
2022-Jan-19 14:04 UTC
[Libguestfs] [nbdkit PATCH 2/2] server/sockets: get rid of AI_ADDRCONFIG
On 01/19/22 14:46, Richard W.M. Jones wrote:> On Tue, Jan 18, 2022 at 11:19:18AM -0600, Eric Blake wrote: >> On Tue, Jan 18, 2022 at 02:48:33PM +0100, Laszlo Ersek wrote: >>> + case '4': >>> + tcpip_sock_af = AF_INET; >>> + break; >>> + >>> + case '6': >>> + tcpip_sock_af = AF_INET6; >>> + break; >> >> Thus, if the user uses nbdkit -46 (or -64), the last one specified >> silently overrides the earlier one, rather than being diagnosed as >> conflicting or explicitly permitting both. The override effect >> matches the long-option naming --ipv4-only, so I can live with it, but >> I'm also open to the idea of explicitly adding code to diagnose both >> options at the same time as an error, if we think that's friendlier >> than silent override. > > Is that actually an error? -4 -6 says you want to listen on IPv4 and > IPv6 which is redundant but not wrong.No, each of -4 and -6 is a restriction, not a permission, so if they were meant to work together, the set of enabled address families would be empty. They simply should not be specified together. If someone still does, the behavior is well defined, and documented. It would be possible to catch that case and to report an error, but it's not worth the complexity. This is pretty common with standard utilities; here's one example: the -l (--files-with-matches) and -L (--files-without-match) flags of "grep": mkdir x cd x echo a > a echo b > b # prints a grep -r -l a # prints b grep -r -L a # prints b, with -L taking effect grep -r -l -L a # prints a, with -l taking effect grep -r -L -l a Thanks, Laszlo