]> xenbits.xensource.com Git - libvirt.git/commit
nwfilter: fix IP address learning
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 18 May 2018 11:54:52 +0000 (12:54 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 7 Jun 2018 15:58:33 +0000 (16:58 +0100)
commit1e49132dde6ae7ec229e3d7550289f9f558ff59b
treea49dcf3096993c24a177e6c1c1a23bff2de0c798
parent331fcaced2a30f18dcd325913027f8c0fe9cb92f
nwfilter: fix IP address learning

In a previous commit:

  commit d4bf8f415074759baf051644559e04fe78888f8b
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Wed Feb 14 09:43:59 2018 +0000

    nwfilter: handle missing switch enum cases

    Ensure all enum cases are listed in switch statements, or cast away
    enum type in places where we don't wish to cover all cases.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
we changed a switch in the nwfilter learning thread so that it had
explict cases for all enum entries. Unfortunately the parameters in the
method had been declared with incorrect type. The "howDetect" parameter
does *not* accept "enum howDetect" values, rather it accepts a bitmask
of "enum howDetect" values, so it should have been an "int" type.

The caller always passes DETECT_STATIC|DETECT_DHCP, so essentially the
IP addressing learning was completely broken by the above change, as it
never matched any switch case, hitting the default leading to EINVAL.

Stop using a typedef for the parameter name this this is a bitmask,
not a plain enum value. Also stop using switch() since that's misleading
with bitmasks too.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/nwfilter/nwfilter_learnipaddr.c
src/nwfilter/nwfilter_learnipaddr.h