diff options
author | Justin Pettit <jpettit@nicira.com> | 2012-07-27 23:58:24 -0700 |
---|---|---|
committer | Justin Pettit <jpettit@nicira.com> | 2012-07-30 20:54:16 -0700 |
commit | 232dfa4aa32a1a5ba99f671a6fd7de58b2bd8b3c (patch) | |
tree | 79e906f30748df7ee7daf2b8a46b49992816545e /lib/dpif-netdev.c | |
parent | 8a77bb2ec8d25a61955bbb041cf1e45e8966da76 (diff) |
dpif: Allow the port number to be requested when adding an interface.
The datapath allows requesting a specific port number for a port, but
the dpif interface didn't expose it. This commit adds that support.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'lib/dpif-netdev.c')
-rw-r--r-- | lib/dpif-netdev.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 5f7ce8ff..60fae5fa 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -407,7 +407,16 @@ dpif_netdev_port_add(struct dpif *dpif, struct netdev *netdev, struct dp_netdev *dp = get_dp_netdev(dpif); int port_no; - port_no = choose_port(dpif, netdev); + if (*port_nop != UINT16_MAX) { + if (*port_nop >= MAX_PORTS) { + return EFBIG; + } else if (dp->ports[*port_nop]) { + return EBUSY; + } + port_no = *port_nop; + } else { + port_no = choose_port(dpif, netdev); + } if (port_no >= 0) { *port_nop = port_no; return do_add_port(dp, netdev_get_name(netdev), |