mbox series

[iproute2,0/3] do not set IPv6-only options on IPv4 addresses

Message ID cover.1561394228.git.aclaudi@redhat.com
Headers show
Series do not set IPv6-only options on IPv4 addresses | expand

Message

Andrea Claudi June 24, 2019, 5:05 p.m. UTC
'home', 'nodad' and 'mngtmpaddr' options are IPv6-only, but
it is possible to set them on IPv4 addresses, too. This should
not be possible.

Fix this adding a check on the protocol family before setting
the flags, and exiting with invarg() on error.

Andrea Claudi (3):
  ip address: do not set nodad option for IPv4 addresses
  ip address: do not set home option for IPv4 addresses
  ip address: do not set mngtmpaddr option for IPv4 addresses

 ip/ipaddress.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Stephen Hemminger June 24, 2019, 5:20 p.m. UTC | #1
On Mon, 24 Jun 2019 19:05:52 +0200
Andrea Claudi <aclaudi@redhat.com> wrote:

> 'home', 'nodad' and 'mngtmpaddr' options are IPv6-only, but
> it is possible to set them on IPv4 addresses, too. This should
> not be possible.
> 
> Fix this adding a check on the protocol family before setting
> the flags, and exiting with invarg() on error.
> 
> Andrea Claudi (3):
>   ip address: do not set nodad option for IPv4 addresses
>   ip address: do not set home option for IPv4 addresses
>   ip address: do not set mngtmpaddr option for IPv4 addresses
> 
>  ip/ipaddress.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 

Maybe this should be a warning, not a failure.
A little concerned that there will be some user with a scripted setup
that this breaks.
Andrea Claudi June 24, 2019, 9:38 p.m. UTC | #2
On Mon, Jun 24, 2019 at 7:21 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Mon, 24 Jun 2019 19:05:52 +0200
> Andrea Claudi <aclaudi@redhat.com> wrote:
>
> > 'home', 'nodad' and 'mngtmpaddr' options are IPv6-only, but
> > it is possible to set them on IPv4 addresses, too. This should
> > not be possible.
> >
> > Fix this adding a check on the protocol family before setting
> > the flags, and exiting with invarg() on error.
> >
> > Andrea Claudi (3):
> >   ip address: do not set nodad option for IPv4 addresses
> >   ip address: do not set home option for IPv4 addresses
> >   ip address: do not set mngtmpaddr option for IPv4 addresses
> >
> >  ip/ipaddress.c | 15 ++++++++++++---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> >
>
> Maybe this should be a warning, not a failure.
> A little concerned that there will be some user with a scripted setup
> that this breaks.

Hi Stephen,
I think that if a script wrongly uses some of these flags on a IPv4
address, it most probably operates on an unexpected address, since
everyone is aware that these flags are IPv6 only. In other words we
are breaking a scripted setup that is already broken.
In this case it's probably worth exiting with error and give the
author the chance to fix the script, otherwise the error can go
unnoticed.

If you prefer, I can send a v2 with warnings instead of errors, just
let me know.

Regards,
Andrea
David Ahern June 24, 2019, 9:51 p.m. UTC | #3
On 6/24/19 3:38 PM, Andrea Claudi wrote:
> I think that if a script wrongly uses some of these flags on a IPv4
> address, it most probably operates on an unexpected address, since
> everyone is aware that these flags are IPv6 only. In other words we
> are breaking a scripted setup that is already broken.
> In this case it's probably worth exiting with error and give the
> author the chance to fix the script, otherwise the error can go
> unnoticed.
> 
> If you prefer, I can send a v2 with warnings instead of errors, just
> let me know.

Recent changes for strict mode have shown people do interesting things
with scripts and like the silent "ignores". :-(