aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_bridge.c
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2015-06-13 19:39:21 +0000
committerKristof Provost <kp@FreeBSD.org>2015-06-13 19:39:21 +0000
commit581e69703607858d2661b32fce87e53ad4602ab4 (patch)
tree515723ac1226443c262e796dae6434fde743ec1e /sys/net/if_bridge.c
parentf2c41c554db2b5c559c18e800001b859687afffa (diff)
downloadsrc-581e69703607858d2661b32fce87e53ad4602ab4.tar.gz
src-581e69703607858d2661b32fce87e53ad4602ab4.zip
Fix panic when adding vtnet interfaces to a bridge
vtnet interfaces are always in promiscuous mode (at least if the VIRTIO_NET_F_CTRL_RX feature is not negotiated with the host). if_promisc() on a vtnet interface returned ENOTSUP although it has IFF_PROMISC set. This confused the bridge code. Instead we now accept all enable/disable promiscuous commands (and always keep IFF_PROMISC set). There are also two issues with the if_bridge error handling. If if_promisc() fails it uses bridge_delete_member() to clean up. This tries to disable promiscuous mode on the interface. That runs into an assert, because promiscuous mode was never set in the first place. (That's the panic reported in PR 200210.) We can only unset promiscuous mode if the interface actually is promiscuous. This goes against the reference counting done by if_promisc(), but only the first/last if_promic() calls can actually fail, so this is safe. A second issue is a double free of bif. It's already freed by bridge_delete_member(). PR: 200210 Differential Revision: https://reviews.freebsd.org/D2804 Reviewed by: philip (mentor)
Notes
Notes: svn path=/head/; revision=284348
Diffstat (limited to 'sys/net/if_bridge.c')
-rw-r--r--sys/net/if_bridge.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index faa7681d8878..c6bcfdf80fe0 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -1033,9 +1033,12 @@ bridge_delete_member(struct bridge_softc *sc, struct bridge_iflist *bif,
case IFT_ETHER:
case IFT_L2VLAN:
/*
- * Take the interface out of promiscuous mode.
+ * Take the interface out of promiscuous mode, but only
+ * if it was promiscuous in the first place. It might
+ * not be if we're in the bridge_ioctl_add() error path.
*/
- (void) ifpromisc(ifs, 0);
+ if (ifs->if_flags & IFF_PROMISC)
+ (void) ifpromisc(ifs, 0);
break;
case IFT_GIF:
@@ -1203,10 +1206,8 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg)
break;
}
- if (error) {
+ if (error)
bridge_delete_member(sc, bif, 0);
- free(bif, M_DEVBUF);
- }
return (error);
}