NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/49043: brconfig bridge0 ipf should not return "Invalid argument" when !BRIDGE_IPF

>Number:         49043
>Category:       kern
>Synopsis:       brconfig bridge0 ipf should not return "Invalid argument" when 
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 28 03:25:00 +0000 2014
>Originator:     Ryota Ozaki
>Release:        current
NetBSD kvm 6.99.49 NetBSD 6.99.49 (KVM) #86: Mon Jul 28 11:58:27 JST 2014  
ozaki-r@hidden:/hidden amd64
When BRIDGE_IPF isn't enabled in the kernel, brconfig bridge0 ipf shows:
  brconfig: ipf: Invalid argument
but the error isn't appropriate because the argument is valid.

Instead we should show a message something like "the function is not supported".
Boot a kernel with BRIDGE_IPF disabled, and run:
  ifconfig bridge0 create
  brconfig bridge0 ipf

brconfig shows "Invalid argument" because the kernel returns EINVAL.
So a simple solution is to let the kernel return ENOTSUP when BRIDGE_IPF
is not enabled. Then brconfig will show "brconfig: ipf: Not supported".
To make the message better, modifying brconfig to check the errno
and show "ipf is not supported in the kernel" or something would be nice.

The following patch is for the simple solution.

diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 4dec613..816a4bc 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -246,9 +246,9 @@ static int  bridge_ioctl_gma(struct bridge_softc *, void *);
 static int     bridge_ioctl_sma(struct bridge_softc *, void *);
 static int     bridge_ioctl_sifprio(struct bridge_softc *, void *);
 static int     bridge_ioctl_sifcost(struct bridge_softc *, void *);
-#if defined(BRIDGE_IPF)
 static int     bridge_ioctl_gfilt(struct bridge_softc *, void *);
 static int     bridge_ioctl_sfilt(struct bridge_softc *, void *);
+#if defined(BRIDGE_IPF)
 static int     bridge_ipf(void *, struct mbuf **, struct ifnet *, int);
 static int     bridge_ip_checkbasic(struct mbuf **mp);
 # ifdef INET6
@@ -306,10 +306,8 @@ static const struct bridge_control bridge_control_table[] 
= {
 [BRDGSIFPRIO] = {bridge_ioctl_sifprio, sizeof(struct ifbreq), 
 [BRDGSIFCOST] = {bridge_ioctl_sifcost, sizeof(struct ifbreq), 
-#if defined(BRIDGE_IPF)
 [BRDGGFILT] = {bridge_ioctl_gfilt, sizeof(struct ifbrparam), BC_F_COPYOUT},
 [BRDGSFILT] = {bridge_ioctl_sfilt, sizeof(struct ifbrparam), 
-#endif /* BRIDGE_IPF */
 static const int bridge_control_table_size = 
@@ -1277,6 +1275,18 @@ bridge_ioctl_sfilt(struct bridge_softc *sc, void *arg)
        return (0);
+static int
+bridge_ioctl_gfilt(struct bridge_softc *sc, void *arg)
+       return ENOTSUP;
+static int
+bridge_ioctl_sfilt(struct bridge_softc *sc, void *arg)
+       return ENOTSUP;
 #endif /* BRIDGE_IPF */
 static int

Home | Main Index | Thread Index | Old Index