git://git.onelab.eu
/
sliver-openvswitch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e3d722e
)
Allow multiple ports on dpctl addif and delif commands, for convenience.
author
Ben Pfaff
<blp@nicira.com>
Tue, 19 Aug 2008 20:47:17 +0000
(13:47 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Tue, 26 Aug 2008 19:02:59 +0000
(12:02 -0700)
utilities/dpctl.8
patch
|
blob
|
history
utilities/dpctl.c
patch
|
blob
|
history
diff --git
a/utilities/dpctl.8
b/utilities/dpctl.8
index
c91166a
..
2af2f27
100644
(file)
--- a/
utilities/dpctl.8
+++ b/
utilities/dpctl.8
@@
-70,8
+70,8
@@
explicitly removed before the datapath can be deleted (see \fBdelif\fR
command).
.TP
command).
.TP
-\fBaddif nl:\fIdp_idx netdev\fR
-Adds \fInetdev\fR to the list of network devices datapath
+\fBaddif nl:\fIdp_idx netdev\fR
...
+Adds
each
\fInetdev\fR to the list of network devices datapath
\fIdp_idx\fR monitors, where \fIdp_idx\fR is the ID of an existing
datapath, and \fInetdev\fR is the name of one of the host's
network devices, e.g. \fBeth0\fR. Once a network device has been added
\fIdp_idx\fR monitors, where \fIdp_idx\fR is the ID of an existing
datapath, and \fInetdev\fR is the name of one of the host's
network devices, e.g. \fBeth0\fR. Once a network device has been added
@@
-79,8
+79,8
@@
to a datapath, the datapath has complete ownership of the network device's
traffic and the network device appears silent to the rest of the system.
.TP
traffic and the network device appears silent to the rest of the system.
.TP
-\fBdelif nl:\fIdp_idx netdev\fR
-Removes \fInetdev\fR from the list of network devices datapath
+\fBdelif nl:\fIdp_idx netdev\fR
...
+Removes
each
\fInetdev\fR from the list of network devices datapath
\fIdp_idx\fR monitors.
.TP
\fIdp_idx\fR monitors.
.TP
diff --git
a/utilities/dpctl.c
b/utilities/dpctl.c
index
7c50200
..
bade78a
100644
(file)
--- a/
utilities/dpctl.c
+++ b/
utilities/dpctl.c
@@
-187,8
+187,8
@@
usage(void)
"\nFor local datapaths only:\n"
" adddp nl:DP_ID add a new local datapath DP_ID\n"
" deldp nl:DP_ID delete local datapath DP_ID\n"
"\nFor local datapaths only:\n"
" adddp nl:DP_ID add a new local datapath DP_ID\n"
" deldp nl:DP_ID delete local datapath DP_ID\n"
- " addif nl:DP_ID IFACE
add
IFACE as a port on DP_ID\n"
- " delif nl:DP_ID IFACE
delete IFACE as a port on
DP_ID\n"
+ " addif nl:DP_ID IFACE
... add each
IFACE as a port on DP_ID\n"
+ " delif nl:DP_ID IFACE
... delete each IFACE from
DP_ID\n"
" monitor nl:DP_ID print packets received\n"
#endif
"\nFor local datapaths and remote switches:\n"
" monitor nl:DP_ID print packets received\n"
#endif
"\nFor local datapaths and remote switches:\n"
@@
-280,21
+280,43
@@
static void do_del_dp(int argc UNUSED, char *argv[])
dpif_close(&dp);
}
dpif_close(&dp);
}
-static void do_add_port(int argc UNUSED, char *argv[])
+static void add_del_ports(int argc UNUSED, char *argv[],
+ int (*function)(struct dpif *, const char *netdev),
+ const char *operation, const char *preposition)
{
struct dpif dp;
{
struct dpif dp;
- if_up(argv[2]);
+ bool failure = false;
+ int i;
+
open_nl_vconn(argv[1], false, &dp);
open_nl_vconn(argv[1], false, &dp);
- run(dpif_add_port(&dp, argv[2]), "add_port");
+ for (i = 2; i < argc; i++) {
+ int retval = function(&dp, argv[i]);
+ if (retval) {
+ error(retval, "failed to %s %s %s %s",
+ operation, argv[i], preposition, argv[1]);
+ failure = true;
+ }
+ }
dpif_close(&dp);
dpif_close(&dp);
+ if (failure) {
+ exit(EXIT_FAILURE);
+ }
+}
+
+static int ifup_and_add_port(struct dpif *dpif, const char *netdev)
+{
+ if_up(netdev);
+ return dpif_add_port(dpif, netdev);
+}
+
+static void do_add_port(int argc UNUSED, char *argv[])
+{
+ add_del_ports(argc, argv, ifup_and_add_port, "add", "to");
}
static void do_del_port(int argc UNUSED, char *argv[])
{
}
static void do_del_port(int argc UNUSED, char *argv[])
{
- struct dpif dp;
- open_nl_vconn(argv[1], false, &dp);
- run(dpif_del_port(&dp, argv[2]), "del_port");
- dpif_close(&dp);
+ add_del_ports(argc, argv, dpif_del_port, "remove", "from");
}
static void do_monitor(int argc UNUSED, char *argv[])
}
static void do_monitor(int argc UNUSED, char *argv[])
@@
-1060,8
+1082,8
@@
static struct command all_commands[] = {
#ifdef HAVE_NETLINK
{ "adddp", 1, 1, do_add_dp },
{ "deldp", 1, 1, do_del_dp },
#ifdef HAVE_NETLINK
{ "adddp", 1, 1, do_add_dp },
{ "deldp", 1, 1, do_del_dp },
- { "addif", 2,
2
, do_add_port },
- { "delif", 2,
2
, do_del_port },
+ { "addif", 2,
INT_MAX
, do_add_port },
+ { "delif", 2,
INT_MAX
, do_del_port },
#endif
{ "show", 1, 1, do_show },
#endif
{ "show", 1, 1, do_show },