[ovs-dev] [PATCH 2/2] dpif-netdev: Do not allow adding loopback devices
Alexandru Copot
alex.mihai.c at gmail.com
Sat Sep 7 09:35:15 UTC 2013
Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
---
lib/dpif-netdev.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 46eb743..0d489ba 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -407,6 +407,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
struct dp_netdev_port *port;
struct netdev *netdev;
struct netdev_rx *rx;
+ enum netdev_flags flags;
const char *open_type;
int mtu;
int error;
@@ -419,9 +420,15 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
if (error) {
return error;
}
- /* XXX reject loopback devices */
/* XXX reject non-Ethernet devices */
+ netdev_get_flags(netdev, &flags);
+ if (flags & NETDEV_LOOPBACK) {
+ VLOG_ERR("%s: cannot add a loopback device", devname);
+ netdev_close(netdev);
+ return EINVAL;
+ }
+
error = netdev_rx_open(netdev, &rx);
if (error
&& !(error == EOPNOTSUPP && dpif_netdev_class_is_dummy(dp->class))) {
--
1.8.4
More information about the dev
mailing list