mirror of
https://github.com/openvswitch/ovs
synced 2025-09-02 15:25:22 +00:00
dpif: Hide the contents of struct dpif.
This helps prepare for multiple dpif implementations, and ensures that code outside dpif.c does not depend on its internals.
This commit is contained in:
57
lib/dpif.c
57
lib/dpif.c
@@ -49,6 +49,13 @@
|
|||||||
#include "vlog.h"
|
#include "vlog.h"
|
||||||
#define THIS_MODULE VLM_dpif
|
#define THIS_MODULE VLM_dpif
|
||||||
|
|
||||||
|
/* A datapath interface. */
|
||||||
|
struct dpif {
|
||||||
|
char *name;
|
||||||
|
unsigned int minor;
|
||||||
|
int fd;
|
||||||
|
};
|
||||||
|
|
||||||
/* Rate limit for individual messages going to or from the datapath, output at
|
/* Rate limit for individual messages going to or from the datapath, output at
|
||||||
* DBG level. This is very high because, if these are enabled, it is because
|
* DBG level. This is very high because, if these are enabled, it is because
|
||||||
* we really need to see them. */
|
* we really need to see them. */
|
||||||
@@ -60,24 +67,26 @@ static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(9999, 5);
|
|||||||
static int get_minor_from_name(const char *name, unsigned int *minor);
|
static int get_minor_from_name(const char *name, unsigned int *minor);
|
||||||
static int name_to_minor(const char *name, unsigned int *minor);
|
static int name_to_minor(const char *name, unsigned int *minor);
|
||||||
static int lookup_minor(const char *name, unsigned int *minor);
|
static int lookup_minor(const char *name, unsigned int *minor);
|
||||||
static int open_by_minor(unsigned int minor, struct dpif *);
|
static int open_by_minor(unsigned int minor, struct dpif **dpifp);
|
||||||
static int make_openvswitch_device(unsigned int minor, char **fnp);
|
static int make_openvswitch_device(unsigned int minor, char **fnp);
|
||||||
static void check_rw_odp_flow(struct odp_flow *);
|
static void check_rw_odp_flow(struct odp_flow *);
|
||||||
|
|
||||||
int
|
int
|
||||||
dpif_open(const char *name, struct dpif *dpif)
|
dpif_open(const char *name, struct dpif **dpifp)
|
||||||
{
|
{
|
||||||
|
struct dpif *dpif;
|
||||||
|
unsigned int minor;
|
||||||
int listen_mask;
|
int listen_mask;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
dpif->fd = -1;
|
*dpifp = NULL;
|
||||||
|
|
||||||
error = name_to_minor(name, &dpif->minor);
|
error = name_to_minor(name, &minor);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = open_by_minor(dpif->minor, dpif);
|
error = open_by_minor(minor, &dpif);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -95,6 +104,7 @@ dpif_open(const char *name, struct dpif *dpif)
|
|||||||
dpif_close(dpif);
|
dpif_close(dpif);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
*dpifp = dpif;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,9 +113,8 @@ dpif_close(struct dpif *dpif)
|
|||||||
{
|
{
|
||||||
if (dpif) {
|
if (dpif) {
|
||||||
free(dpif->name);
|
free(dpif->name);
|
||||||
dpif->name = NULL;
|
|
||||||
close(dpif->fd);
|
close(dpif->fd);
|
||||||
dpif->fd = -1;
|
free(dpif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,14 +136,17 @@ do_ioctl(const struct dpif *dpif, int cmd, const char *cmd_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
dpif_create(const char *name, struct dpif *dpif)
|
dpif_create(const char *name, struct dpif **dpifp)
|
||||||
{
|
{
|
||||||
unsigned int minor;
|
unsigned int minor;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
*dpifp = NULL;
|
||||||
if (!get_minor_from_name(name, &minor)) {
|
if (!get_minor_from_name(name, &minor)) {
|
||||||
/* Minor was specified in 'name', go ahead and create it. */
|
/* Minor was specified in 'name', go ahead and create it. */
|
||||||
error = open_by_minor(minor, dpif);
|
struct dpif *dpif;
|
||||||
|
|
||||||
|
error = open_by_minor(minor, &dpif);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -146,19 +158,24 @@ dpif_create(const char *name, struct dpif *dpif)
|
|||||||
} else {
|
} else {
|
||||||
error = ioctl(dpif->fd, ODP_DP_CREATE, name) < 0 ? errno : 0;
|
error = ioctl(dpif->fd, ODP_DP_CREATE, name) < 0 ? errno : 0;
|
||||||
}
|
}
|
||||||
if (error) {
|
if (!error) {
|
||||||
|
*dpifp = dpif;
|
||||||
|
} else {
|
||||||
dpif_close(dpif);
|
dpif_close(dpif);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
} else {
|
} else {
|
||||||
for (minor = 0; minor < ODP_MAX; minor++) {
|
for (minor = 0; minor < ODP_MAX; minor++) {
|
||||||
error = open_by_minor(minor, dpif);
|
struct dpif *dpif;
|
||||||
|
|
||||||
|
error = open_by_minor(minor, &dpif);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ioctl(dpif->fd, ODP_DP_CREATE, name) < 0 ? errno : 0;
|
error = ioctl(dpif->fd, ODP_DP_CREATE, name) < 0 ? errno : 0;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
*dpifp = dpif;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dpif_close(dpif);
|
dpif_close(dpif);
|
||||||
@@ -700,7 +717,7 @@ dpif_get_netflow_ids(const struct dpif *dpif,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct dpifmon {
|
struct dpifmon {
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
struct nl_sock *sock;
|
struct nl_sock *sock;
|
||||||
int local_ifindex;
|
int local_ifindex;
|
||||||
};
|
};
|
||||||
@@ -718,7 +735,7 @@ dpifmon_create(const char *datapath_name, struct dpifmon **monp)
|
|||||||
if (error) {
|
if (error) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
error = dpif_port_get_name(&mon->dpif, ODPP_LOCAL,
|
error = dpif_port_get_name(mon->dpif, ODPP_LOCAL,
|
||||||
local_name, sizeof local_name);
|
local_name, sizeof local_name);
|
||||||
if (error) {
|
if (error) {
|
||||||
goto error_close_dpif;
|
goto error_close_dpif;
|
||||||
@@ -741,7 +758,7 @@ dpifmon_create(const char *datapath_name, struct dpifmon **monp)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_close_dpif:
|
error_close_dpif:
|
||||||
dpif_close(&mon->dpif);
|
dpif_close(mon->dpif);
|
||||||
error:
|
error:
|
||||||
free(mon);
|
free(mon);
|
||||||
*monp = NULL;
|
*monp = NULL;
|
||||||
@@ -752,7 +769,7 @@ void
|
|||||||
dpifmon_destroy(struct dpifmon *mon)
|
dpifmon_destroy(struct dpifmon *mon)
|
||||||
{
|
{
|
||||||
if (mon) {
|
if (mon) {
|
||||||
dpif_close(&mon->dpif);
|
dpif_close(mon->dpif);
|
||||||
nl_sock_destroy(mon->sock);
|
nl_sock_destroy(mon->sock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1025,14 +1042,14 @@ get_minor_from_name(const char *name, unsigned int *minor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
open_by_minor(unsigned int minor, struct dpif *dpif)
|
open_by_minor(unsigned int minor, struct dpif **dpifp)
|
||||||
{
|
{
|
||||||
|
struct dpif *dpif;
|
||||||
int error;
|
int error;
|
||||||
char *fn;
|
char *fn;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
dpif->minor = -1;
|
*dpifp = NULL;
|
||||||
dpif->fd = -1;
|
|
||||||
error = make_openvswitch_device(minor, &fn);
|
error = make_openvswitch_device(minor, &fn);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
@@ -1045,11 +1062,13 @@ open_by_minor(unsigned int minor, struct dpif *dpif)
|
|||||||
free(fn);
|
free(fn);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fn);
|
free(fn);
|
||||||
|
|
||||||
|
dpif = xmalloc(sizeof *dpif);
|
||||||
dpif->name = xasprintf("dp%u", dpif->minor);
|
dpif->name = xasprintf("dp%u", dpif->minor);
|
||||||
dpif->minor = minor;
|
dpif->minor = minor;
|
||||||
dpif->fd = fd;
|
dpif->fd = fd;
|
||||||
|
*dpifp = dpif;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
lib/dpif.h
12
lib/dpif.h
@@ -27,17 +27,11 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct dpif;
|
||||||
struct ofpbuf;
|
struct ofpbuf;
|
||||||
|
|
||||||
/* A datapath interface. Opaque. */
|
int dpif_open(const char *name, struct dpif **);
|
||||||
struct dpif {
|
int dpif_create(const char *name, struct dpif **);
|
||||||
char *name;
|
|
||||||
unsigned int minor;
|
|
||||||
int fd;
|
|
||||||
};
|
|
||||||
|
|
||||||
int dpif_open(const char *name, struct dpif *);
|
|
||||||
int dpif_create(const char *name, struct dpif *);
|
|
||||||
void dpif_close(struct dpif *);
|
void dpif_close(struct dpif *);
|
||||||
|
|
||||||
const char *dpif_name(const struct dpif *);
|
const char *dpif_name(const struct dpif *);
|
||||||
|
@@ -192,7 +192,7 @@ struct ofproto {
|
|||||||
char *serial; /* Serial number. */
|
char *serial; /* Serial number. */
|
||||||
|
|
||||||
/* Datapath. */
|
/* Datapath. */
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
struct dpifmon *dpifmon;
|
struct dpifmon *dpifmon;
|
||||||
struct port_array ports; /* Index is ODP port nr; ofport->opp.port_no is
|
struct port_array ports; /* Index is ODP port nr; ofport->opp.port_no is
|
||||||
* OFP port nr. */
|
* OFP port nr. */
|
||||||
@@ -262,7 +262,7 @@ ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux,
|
|||||||
struct dpifmon *dpifmon;
|
struct dpifmon *dpifmon;
|
||||||
struct odp_stats stats;
|
struct odp_stats stats;
|
||||||
struct ofproto *p;
|
struct ofproto *p;
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
*ofprotop = NULL;
|
*ofprotop = NULL;
|
||||||
@@ -273,36 +273,36 @@ ofproto_create(const char *datapath, const struct ofhooks *ofhooks, void *aux,
|
|||||||
VLOG_ERR("failed to open datapath %s: %s", datapath, strerror(error));
|
VLOG_ERR("failed to open datapath %s: %s", datapath, strerror(error));
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
error = dpif_get_dp_stats(&dpif, &stats);
|
error = dpif_get_dp_stats(dpif, &stats);
|
||||||
if (error) {
|
if (error) {
|
||||||
VLOG_ERR("failed to obtain stats for datapath %s: %s",
|
VLOG_ERR("failed to obtain stats for datapath %s: %s",
|
||||||
datapath, strerror(error));
|
datapath, strerror(error));
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
error = dpif_set_listen_mask(&dpif, ODPL_MISS | ODPL_ACTION);
|
error = dpif_set_listen_mask(dpif, ODPL_MISS | ODPL_ACTION);
|
||||||
if (error) {
|
if (error) {
|
||||||
VLOG_ERR("failed to listen on datapath %s: %s",
|
VLOG_ERR("failed to listen on datapath %s: %s",
|
||||||
datapath, strerror(error));
|
datapath, strerror(error));
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
dpif_flow_flush(&dpif);
|
dpif_flow_flush(dpif);
|
||||||
dpif_purge(&dpif);
|
dpif_purge(dpif);
|
||||||
|
|
||||||
/* Start monitoring datapath ports for status changes. */
|
/* Start monitoring datapath ports for status changes. */
|
||||||
error = dpifmon_create(datapath, &dpifmon);
|
error = dpifmon_create(datapath, &dpifmon);
|
||||||
if (error) {
|
if (error) {
|
||||||
VLOG_ERR("failed to starting monitoring datapath %s: %s",
|
VLOG_ERR("failed to starting monitoring datapath %s: %s",
|
||||||
datapath, strerror(error));
|
datapath, strerror(error));
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize settings. */
|
/* Initialize settings. */
|
||||||
p = xcalloc(1, sizeof *p);
|
p = xcalloc(1, sizeof *p);
|
||||||
p->fallback_dpid = pick_fallback_dpid();
|
p->fallback_dpid = pick_fallback_dpid();
|
||||||
p->datapath_id = pick_datapath_id(&dpif, p->fallback_dpid);
|
p->datapath_id = pick_datapath_id(dpif, p->fallback_dpid);
|
||||||
VLOG_INFO("using datapath ID %012"PRIx64, p->datapath_id);
|
VLOG_INFO("using datapath ID %012"PRIx64, p->datapath_id);
|
||||||
p->manufacturer = xstrdup("Nicira Networks, Inc.");
|
p->manufacturer = xstrdup("Nicira Networks, Inc.");
|
||||||
p->hardware = xstrdup("Reference Implementation");
|
p->hardware = xstrdup("Reference Implementation");
|
||||||
@@ -373,7 +373,7 @@ ofproto_set_datapath_id(struct ofproto *p, uint64_t datapath_id)
|
|||||||
uint64_t old_dpid = p->datapath_id;
|
uint64_t old_dpid = p->datapath_id;
|
||||||
p->datapath_id = (datapath_id
|
p->datapath_id = (datapath_id
|
||||||
? datapath_id
|
? datapath_id
|
||||||
: pick_datapath_id(&p->dpif, p->fallback_dpid));
|
: pick_datapath_id(p->dpif, p->fallback_dpid));
|
||||||
if (p->datapath_id != old_dpid) {
|
if (p->datapath_id != old_dpid) {
|
||||||
VLOG_INFO("datapath ID changed to %012"PRIx64, p->datapath_id);
|
VLOG_INFO("datapath ID changed to %012"PRIx64, p->datapath_id);
|
||||||
rconn_reconnect(p->controller->rconn);
|
rconn_reconnect(p->controller->rconn);
|
||||||
@@ -431,7 +431,7 @@ ofproto_set_in_band(struct ofproto *p, bool in_band)
|
|||||||
{
|
{
|
||||||
if (in_band != (p->in_band != NULL)) {
|
if (in_band != (p->in_band != NULL)) {
|
||||||
if (in_band) {
|
if (in_band) {
|
||||||
return in_band_create(p, &p->dpif, p->switch_status,
|
return in_band_create(p, p->dpif, p->switch_status,
|
||||||
p->controller->rconn, &p->in_band);
|
p->controller->rconn, &p->in_band);
|
||||||
} else {
|
} else {
|
||||||
ofproto_set_discovery(p, false, NULL, true);
|
ofproto_set_discovery(p, false, NULL, true);
|
||||||
@@ -454,7 +454,7 @@ ofproto_set_discovery(struct ofproto *p, bool discovery,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
error = discovery_create(re, update_resolv_conf,
|
error = discovery_create(re, update_resolv_conf,
|
||||||
&p->dpif, p->switch_status,
|
p->dpif, p->switch_status,
|
||||||
&p->discovery);
|
&p->discovery);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
@@ -705,7 +705,7 @@ ofproto_destroy(struct ofproto *p)
|
|||||||
ofconn_destroy(ofconn, p);
|
ofconn_destroy(ofconn, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
dpif_close(&p->dpif);
|
dpif_close(p->dpif);
|
||||||
dpifmon_destroy(p->dpifmon);
|
dpifmon_destroy(p->dpifmon);
|
||||||
PORT_ARRAY_FOR_EACH (ofport, &p->ports, port_no) {
|
PORT_ARRAY_FOR_EACH (ofport, &p->ports, port_no) {
|
||||||
ofport_free(ofport);
|
ofport_free(ofport);
|
||||||
@@ -760,7 +760,7 @@ ofproto_run1(struct ofproto *p)
|
|||||||
struct ofpbuf *buf;
|
struct ofpbuf *buf;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = dpif_recv(&p->dpif, &buf);
|
error = dpif_recv(p->dpif, &buf);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error == ENODEV) {
|
if (error == ENODEV) {
|
||||||
/* Someone destroyed the datapath behind our back. The caller
|
/* Someone destroyed the datapath behind our back. The caller
|
||||||
@@ -768,7 +768,7 @@ ofproto_run1(struct ofproto *p)
|
|||||||
* spin from here on out. */
|
* spin from here on out. */
|
||||||
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
||||||
VLOG_ERR_RL(&rl, "%s: datapath was destroyed externally",
|
VLOG_ERR_RL(&rl, "%s: datapath was destroyed externally",
|
||||||
dpif_name(&p->dpif));
|
dpif_name(p->dpif));
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -895,7 +895,7 @@ ofproto_wait(struct ofproto *p)
|
|||||||
struct ofconn *ofconn;
|
struct ofconn *ofconn;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
dpif_recv_wait(&p->dpif);
|
dpif_recv_wait(p->dpif);
|
||||||
dpifmon_wait(p->dpifmon);
|
dpifmon_wait(p->dpifmon);
|
||||||
LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) {
|
LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) {
|
||||||
ofconn_wait(ofconn);
|
ofconn_wait(ofconn);
|
||||||
@@ -966,7 +966,7 @@ ofproto_send_packet(struct ofproto *p, const flow_t *flow,
|
|||||||
|
|
||||||
/* XXX Should we translate the dpif_execute() errno value into an OpenFlow
|
/* XXX Should we translate the dpif_execute() errno value into an OpenFlow
|
||||||
* error code? */
|
* error code? */
|
||||||
dpif_execute(&p->dpif, flow->in_port, odp_actions.actions,
|
dpif_execute(p->dpif, flow->in_port, odp_actions.actions,
|
||||||
odp_actions.n_actions, packet);
|
odp_actions.n_actions, packet);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1018,7 +1018,7 @@ ofproto_flush_flows(struct ofproto *ofproto)
|
|||||||
{
|
{
|
||||||
COVERAGE_INC(ofproto_flush);
|
COVERAGE_INC(ofproto_flush);
|
||||||
classifier_for_each(&ofproto->cls, CLS_INC_ALL, destroy_rule, ofproto);
|
classifier_for_each(&ofproto->cls, CLS_INC_ALL, destroy_rule, ofproto);
|
||||||
dpif_flow_flush(&ofproto->dpif);
|
dpif_flow_flush(ofproto->dpif);
|
||||||
if (ofproto->in_band) {
|
if (ofproto->in_band) {
|
||||||
in_band_flushed(ofproto->in_band);
|
in_band_flushed(ofproto->in_band);
|
||||||
}
|
}
|
||||||
@@ -1041,7 +1041,7 @@ reinit_ports(struct ofproto *p)
|
|||||||
PORT_ARRAY_FOR_EACH (ofport, &p->ports, port_no) {
|
PORT_ARRAY_FOR_EACH (ofport, &p->ports, port_no) {
|
||||||
svec_add (&devnames, (char *) ofport->opp.name);
|
svec_add (&devnames, (char *) ofport->opp.name);
|
||||||
}
|
}
|
||||||
dpif_port_list(&p->dpif, &odp_ports, &n_odp_ports);
|
dpif_port_list(p->dpif, &odp_ports, &n_odp_ports);
|
||||||
for (i = 0; i < n_odp_ports; i++) {
|
for (i = 0; i < n_odp_ports; i++) {
|
||||||
svec_add (&devnames, odp_ports[i].devname);
|
svec_add (&devnames, odp_ports[i].devname);
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1071,7 @@ refresh_port_group(struct ofproto *p, unsigned int group)
|
|||||||
ports[n_ports++] = port_no;
|
ports[n_ports++] = port_no;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dpif_port_group_set(&p->dpif, group, ports, n_ports);
|
dpif_port_group_set(p->dpif, group, ports, n_ports);
|
||||||
free(ports);
|
free(ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,7 +1209,7 @@ update_port(struct ofproto *p, const char *devname)
|
|||||||
|
|
||||||
COVERAGE_INC(ofproto_update_port);
|
COVERAGE_INC(ofproto_update_port);
|
||||||
ofport = shash_find_data(&p->port_by_name, devname);
|
ofport = shash_find_data(&p->port_by_name, devname);
|
||||||
error = dpif_port_query_by_name(&p->dpif, devname, &odp_port);
|
error = dpif_port_query_by_name(p->dpif, devname, &odp_port);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
if (!ofport) {
|
if (!ofport) {
|
||||||
/* New port. */
|
/* New port. */
|
||||||
@@ -1262,7 +1262,7 @@ init_ports(struct ofproto *p)
|
|||||||
size_t i;
|
size_t i;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = dpif_port_list(&p->dpif, &ports, &n_ports);
|
error = dpif_port_list(p->dpif, &ports, &n_ports);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -1464,7 +1464,7 @@ rule_execute(struct ofproto *ofproto, struct rule *rule,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Execute the ODP actions. */
|
/* Execute the ODP actions. */
|
||||||
if (!dpif_execute(&ofproto->dpif, flow->in_port,
|
if (!dpif_execute(ofproto->dpif, flow->in_port,
|
||||||
actions, n_actions, packet)) {
|
actions, n_actions, packet)) {
|
||||||
struct odp_flow_stats stats;
|
struct odp_flow_stats stats;
|
||||||
flow_extract_stats(flow, packet, &stats);
|
flow_extract_stats(flow, packet, &stats);
|
||||||
@@ -1573,7 +1573,7 @@ do_put_flow(struct ofproto *ofproto, struct rule *rule, int flags,
|
|||||||
put->flow.actions = rule->odp_actions;
|
put->flow.actions = rule->odp_actions;
|
||||||
put->flow.n_actions = rule->n_odp_actions;
|
put->flow.n_actions = rule->n_odp_actions;
|
||||||
put->flags = flags;
|
put->flags = flags;
|
||||||
return dpif_flow_put(&ofproto->dpif, put);
|
return dpif_flow_put(ofproto->dpif, put);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1654,7 +1654,7 @@ rule_uninstall(struct ofproto *p, struct rule *rule)
|
|||||||
odp_flow.key = rule->cr.flow;
|
odp_flow.key = rule->cr.flow;
|
||||||
odp_flow.actions = NULL;
|
odp_flow.actions = NULL;
|
||||||
odp_flow.n_actions = 0;
|
odp_flow.n_actions = 0;
|
||||||
if (!dpif_flow_del(&p->dpif, &odp_flow)) {
|
if (!dpif_flow_del(p->dpif, &odp_flow)) {
|
||||||
update_stats(rule, &odp_flow.stats);
|
update_stats(rule, &odp_flow.stats);
|
||||||
}
|
}
|
||||||
rule->installed = false;
|
rule->installed = false;
|
||||||
@@ -1802,7 +1802,7 @@ handle_get_config_request(struct ofproto *p, struct ofconn *ofconn,
|
|||||||
bool drop_frags;
|
bool drop_frags;
|
||||||
|
|
||||||
/* Figure out flags. */
|
/* Figure out flags. */
|
||||||
dpif_get_drop_frags(&p->dpif, &drop_frags);
|
dpif_get_drop_frags(p->dpif, &drop_frags);
|
||||||
flags = drop_frags ? OFPC_FRAG_DROP : OFPC_FRAG_NORMAL;
|
flags = drop_frags ? OFPC_FRAG_DROP : OFPC_FRAG_NORMAL;
|
||||||
if (ofconn->send_flow_exp) {
|
if (ofconn->send_flow_exp) {
|
||||||
flags |= OFPC_SEND_FLOW_EXP;
|
flags |= OFPC_SEND_FLOW_EXP;
|
||||||
@@ -1835,10 +1835,10 @@ handle_set_config(struct ofproto *p, struct ofconn *ofconn,
|
|||||||
if (ofconn == p->controller) {
|
if (ofconn == p->controller) {
|
||||||
switch (flags & OFPC_FRAG_MASK) {
|
switch (flags & OFPC_FRAG_MASK) {
|
||||||
case OFPC_FRAG_NORMAL:
|
case OFPC_FRAG_NORMAL:
|
||||||
dpif_set_drop_frags(&p->dpif, false);
|
dpif_set_drop_frags(p->dpif, false);
|
||||||
break;
|
break;
|
||||||
case OFPC_FRAG_DROP:
|
case OFPC_FRAG_DROP:
|
||||||
dpif_set_drop_frags(&p->dpif, true);
|
dpif_set_drop_frags(p->dpif, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
VLOG_WARN_RL(&rl, "requested bad fragment mode (flags=%"PRIx16")",
|
VLOG_WARN_RL(&rl, "requested bad fragment mode (flags=%"PRIx16")",
|
||||||
@@ -2143,7 +2143,7 @@ handle_packet_out(struct ofproto *p, struct ofconn *ofconn,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
dpif_execute(&p->dpif, flow.in_port, actions.actions, actions.n_actions,
|
dpif_execute(p->dpif, flow.in_port, actions.actions, actions.n_actions,
|
||||||
&payload);
|
&payload);
|
||||||
ofpbuf_delete(buffer);
|
ofpbuf_delete(buffer);
|
||||||
|
|
||||||
@@ -2286,7 +2286,7 @@ handle_table_stats_request(struct ofproto *p, struct ofconn *ofconn,
|
|||||||
n_wild = classifier_count(&p->cls) - classifier_count_exact(&p->cls);
|
n_wild = classifier_count(&p->cls) - classifier_count_exact(&p->cls);
|
||||||
|
|
||||||
/* Hash table. */
|
/* Hash table. */
|
||||||
dpif_get_dp_stats(&p->dpif, &dpstats);
|
dpif_get_dp_stats(p->dpif, &dpstats);
|
||||||
ots = append_stats_reply(sizeof *ots, ofconn, &msg);
|
ots = append_stats_reply(sizeof *ots, ofconn, &msg);
|
||||||
memset(ots, 0, sizeof *ots);
|
memset(ots, 0, sizeof *ots);
|
||||||
ots->table_id = TABLEID_HASH;
|
ots->table_id = TABLEID_HASH;
|
||||||
@@ -2381,7 +2381,7 @@ query_stats(struct ofproto *p, struct rule *rule,
|
|||||||
|
|
||||||
packet_count = rule->packet_count;
|
packet_count = rule->packet_count;
|
||||||
byte_count = rule->byte_count;
|
byte_count = rule->byte_count;
|
||||||
if (!dpif_flow_get_multiple(&p->dpif, odp_flows, n_odp_flows)) {
|
if (!dpif_flow_get_multiple(p->dpif, odp_flows, n_odp_flows)) {
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < n_odp_flows; i++) {
|
for (i = 0; i < n_odp_flows; i++) {
|
||||||
struct odp_flow *odp_flow = &odp_flows[i];
|
struct odp_flow *odp_flow = &odp_flows[i];
|
||||||
@@ -3139,7 +3139,7 @@ update_used(struct ofproto *p)
|
|||||||
size_t i;
|
size_t i;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = dpif_flow_list_all(&p->dpif, &flows, &n_flows);
|
error = dpif_flow_list_all(p->dpif, &flows, &n_flows);
|
||||||
if (error) {
|
if (error) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3152,7 +3152,7 @@ update_used(struct ofproto *p)
|
|||||||
classifier_find_rule_exactly(&p->cls, &f->key, 0, UINT16_MAX));
|
classifier_find_rule_exactly(&p->cls, &f->key, 0, UINT16_MAX));
|
||||||
if (!rule || !rule->installed) {
|
if (!rule || !rule->installed) {
|
||||||
COVERAGE_INC(ofproto_unexpected_rule);
|
COVERAGE_INC(ofproto_unexpected_rule);
|
||||||
dpif_flow_del(&p->dpif, f);
|
dpif_flow_del(p->dpif, f);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -211,9 +211,9 @@ static int if_up(const char *netdev_name)
|
|||||||
static void
|
static void
|
||||||
do_add_dp(int argc UNUSED, char *argv[])
|
do_add_dp(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
run(dpif_create(argv[1], &dpif), "add_dp");
|
run(dpif_create(argv[1], &dpif), "add_dp");
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
do_add_if(argc, argv);
|
do_add_if(argc, argv);
|
||||||
}
|
}
|
||||||
@@ -222,10 +222,10 @@ do_add_dp(int argc UNUSED, char *argv[])
|
|||||||
static void
|
static void
|
||||||
do_del_dp(int argc UNUSED, char *argv[])
|
do_del_dp(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
run(dpif_open(argv[1], &dpif), "opening datapath");
|
run(dpif_open(argv[1], &dpif), "opening datapath");
|
||||||
run(dpif_delete(&dpif), "del_dp");
|
run(dpif_delete(dpif), "del_dp");
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -270,7 +270,7 @@ static void
|
|||||||
do_add_if(int argc UNUSED, char *argv[])
|
do_add_if(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
run(dpif_open(argv[1], &dpif), "opening datapath");
|
run(dpif_open(argv[1], &dpif), "opening datapath");
|
||||||
@@ -320,10 +320,10 @@ do_add_if(int argc UNUSED, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (port < 0) {
|
if (port < 0) {
|
||||||
port = get_free_port(&dpif);
|
port = get_free_port(dpif);
|
||||||
}
|
}
|
||||||
|
|
||||||
error = dpif_port_add(&dpif, devname, port, flags);
|
error = dpif_port_add(dpif, devname, port, flags);
|
||||||
if (error) {
|
if (error) {
|
||||||
ovs_error(error, "adding %s as port %"PRIu16" of %s failed",
|
ovs_error(error, "adding %s as port %"PRIu16" of %s failed",
|
||||||
devname, port, argv[1]);
|
devname, port, argv[1]);
|
||||||
@@ -332,7 +332,7 @@ do_add_if(int argc UNUSED, char *argv[])
|
|||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
if (failure) {
|
if (failure) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -362,7 +362,7 @@ static void
|
|||||||
do_del_if(int argc UNUSED, char *argv[])
|
do_del_if(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
run(dpif_open(argv[1], &dpif), "opening datapath");
|
run(dpif_open(argv[1], &dpif), "opening datapath");
|
||||||
@@ -373,18 +373,18 @@ do_del_if(int argc UNUSED, char *argv[])
|
|||||||
|
|
||||||
if (!name[strspn(name, "0123456789")]) {
|
if (!name[strspn(name, "0123456789")]) {
|
||||||
port = atoi(name);
|
port = atoi(name);
|
||||||
} else if (!get_port_number(&dpif, name, &port)) {
|
} else if (!get_port_number(dpif, name, &port)) {
|
||||||
failure = true;
|
failure = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = dpif_port_del(&dpif, port);
|
error = dpif_port_del(dpif, port);
|
||||||
if (error) {
|
if (error) {
|
||||||
ovs_error(error, "deleting port %s from %s failed", name, argv[1]);
|
ovs_error(error, "deleting port %s from %s failed", name, argv[1]);
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
if (failure) {
|
if (failure) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -432,12 +432,12 @@ do_show(int argc UNUSED, char *argv[])
|
|||||||
int i;
|
int i;
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
const char *name = argv[i];
|
const char *name = argv[i];
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = dpif_open(name, &dpif);
|
error = dpif_open(name, &dpif);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
show_dpif(&dpif);
|
show_dpif(dpif);
|
||||||
} else {
|
} else {
|
||||||
ovs_error(error, "opening datapath %s failed", name);
|
ovs_error(error, "opening datapath %s failed", name);
|
||||||
failure = true;
|
failure = true;
|
||||||
@@ -447,13 +447,13 @@ do_show(int argc UNUSED, char *argv[])
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < ODP_MAX; i++) {
|
for (i = 0; i < ODP_MAX; i++) {
|
||||||
char name[128];
|
char name[128];
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
sprintf(name, "dp%u", i);
|
sprintf(name, "dp%u", i);
|
||||||
error = dpif_open(name, &dpif);
|
error = dpif_open(name, &dpif);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
show_dpif(&dpif);
|
show_dpif(dpif);
|
||||||
} else if (error != ENODEV) {
|
} else if (error != ENODEV) {
|
||||||
ovs_error(error, "opening datapath %s failed", name);
|
ovs_error(error, "opening datapath %s failed", name);
|
||||||
failure = true;
|
failure = true;
|
||||||
@@ -469,13 +469,13 @@ static void
|
|||||||
do_dump_flows(int argc UNUSED, char *argv[])
|
do_dump_flows(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
struct odp_flow *flows;
|
struct odp_flow *flows;
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
size_t n_flows;
|
size_t n_flows;
|
||||||
struct ds ds;
|
struct ds ds;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
run(dpif_open(argv[1], &dpif), "opening datapath");
|
run(dpif_open(argv[1], &dpif), "opening datapath");
|
||||||
run(dpif_flow_list_all(&dpif, &flows, &n_flows), "listing all flows");
|
run(dpif_flow_list_all(dpif, &flows, &n_flows), "listing all flows");
|
||||||
|
|
||||||
ds_init(&ds);
|
ds_init(&ds);
|
||||||
for (i = 0; i < n_flows; i++) {
|
for (i = 0; i < n_flows; i++) {
|
||||||
@@ -485,40 +485,40 @@ do_dump_flows(int argc UNUSED, char *argv[])
|
|||||||
|
|
||||||
f->actions = actions;
|
f->actions = actions;
|
||||||
f->n_actions = MAX_ACTIONS;
|
f->n_actions = MAX_ACTIONS;
|
||||||
dpif_flow_get(&dpif, f);
|
dpif_flow_get(dpif, f);
|
||||||
|
|
||||||
ds_clear(&ds);
|
ds_clear(&ds);
|
||||||
format_odp_flow(&ds, f);
|
format_odp_flow(&ds, f);
|
||||||
printf("%s\n", ds_cstr(&ds));
|
printf("%s\n", ds_cstr(&ds));
|
||||||
}
|
}
|
||||||
ds_destroy(&ds);
|
ds_destroy(&ds);
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_del_flows(int argc UNUSED, char *argv[])
|
do_del_flows(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
|
|
||||||
run(dpif_open(argv[1], &dpif), "opening datapath");
|
run(dpif_open(argv[1], &dpif), "opening datapath");
|
||||||
run(dpif_flow_flush(&dpif), "deleting all flows");
|
run(dpif_flow_flush(dpif), "deleting all flows");
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_dump_groups(int argc UNUSED, char *argv[])
|
do_dump_groups(int argc UNUSED, char *argv[])
|
||||||
{
|
{
|
||||||
struct odp_stats stats;
|
struct odp_stats stats;
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
run(dpif_open(argv[1], &dpif), "opening datapath");
|
run(dpif_open(argv[1], &dpif), "opening datapath");
|
||||||
run(dpif_get_dp_stats(&dpif, &stats), "get datapath stats");
|
run(dpif_get_dp_stats(dpif, &stats), "get datapath stats");
|
||||||
for (i = 0; i < stats.max_groups; i++) {
|
for (i = 0; i < stats.max_groups; i++) {
|
||||||
uint16_t ports[UINT16_MAX];
|
uint16_t ports[UINT16_MAX];
|
||||||
size_t n_ports;
|
size_t n_ports;
|
||||||
|
|
||||||
if (!dpif_port_group_get(&dpif, i, ports,
|
if (!dpif_port_group_get(dpif, i, ports,
|
||||||
ARRAY_SIZE(ports), &n_ports) && n_ports) {
|
ARRAY_SIZE(ports), &n_ports) && n_ports) {
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
@@ -529,7 +529,7 @@ do_dump_groups(int argc UNUSED, char *argv[])
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -251,7 +251,7 @@ static void run(int retval, const char *message, ...)
|
|||||||
static void
|
static void
|
||||||
open_vconn(const char *name, struct vconn **vconnp)
|
open_vconn(const char *name, struct vconn **vconnp)
|
||||||
{
|
{
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
if (strstr(name, ":")) {
|
if (strstr(name, ":")) {
|
||||||
@@ -268,9 +268,9 @@ open_vconn(const char *name, struct vconn **vconnp)
|
|||||||
char *socket_name;
|
char *socket_name;
|
||||||
char *vconn_name;
|
char *vconn_name;
|
||||||
|
|
||||||
run(dpif_port_get_name(&dpif, ODPP_LOCAL, dpif_name, sizeof dpif_name),
|
run(dpif_port_get_name(dpif, ODPP_LOCAL, dpif_name, sizeof dpif_name),
|
||||||
"obtaining name of %s", dpif_name);
|
"obtaining name of %s", dpif_name);
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
if (strcmp(dpif_name, name)) {
|
if (strcmp(dpif_name, name)) {
|
||||||
VLOG_INFO("datapath %s is named %s", name, dpif_name);
|
VLOG_INFO("datapath %s is named %s", name, dpif_name);
|
||||||
}
|
}
|
||||||
|
@@ -158,7 +158,7 @@ struct bridge {
|
|||||||
struct ofproto *ofproto; /* OpenFlow switch. */
|
struct ofproto *ofproto; /* OpenFlow switch. */
|
||||||
|
|
||||||
/* Kernel datapath information. */
|
/* Kernel datapath information. */
|
||||||
struct dpif dpif; /* Kernel datapath. */
|
struct dpif *dpif; /* Datapath. */
|
||||||
struct port_array ifaces; /* Indexed by kernel datapath port number. */
|
struct port_array ifaces; /* Indexed by kernel datapath port number. */
|
||||||
|
|
||||||
/* Bridge ports. */
|
/* Bridge ports. */
|
||||||
@@ -260,7 +260,7 @@ bridge_get_ifaces(struct svec *svec)
|
|||||||
struct iface *iface = port->ifaces[j];
|
struct iface *iface = port->ifaces[j];
|
||||||
if (iface->dp_ifidx < 0) {
|
if (iface->dp_ifidx < 0) {
|
||||||
VLOG_ERR("%s interface not in datapath %s, ignoring",
|
VLOG_ERR("%s interface not in datapath %s, ignoring",
|
||||||
iface->name, dpif_name(&br->dpif));
|
iface->name, dpif_name(br->dpif));
|
||||||
} else {
|
} else {
|
||||||
if (iface->dp_ifidx != ODPP_LOCAL) {
|
if (iface->dp_ifidx != ODPP_LOCAL) {
|
||||||
svec_add(svec, iface->name);
|
svec_add(svec, iface->name);
|
||||||
@@ -281,19 +281,19 @@ bridge_init(void)
|
|||||||
bond_init();
|
bond_init();
|
||||||
|
|
||||||
for (i = 0; i < DP_MAX; i++) {
|
for (i = 0; i < DP_MAX; i++) {
|
||||||
struct dpif dpif;
|
struct dpif *dpif;
|
||||||
char devname[16];
|
char devname[16];
|
||||||
|
|
||||||
sprintf(devname, "dp%d", i);
|
sprintf(devname, "dp%d", i);
|
||||||
retval = dpif_open(devname, &dpif);
|
retval = dpif_open(devname, &dpif);
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
char dpif_name[IF_NAMESIZE];
|
char dpif_name[IF_NAMESIZE];
|
||||||
if (dpif_port_get_name(&dpif, ODPP_LOCAL,
|
if (dpif_port_get_name(dpif, ODPP_LOCAL,
|
||||||
dpif_name, sizeof dpif_name)
|
dpif_name, sizeof dpif_name)
|
||||||
|| !cfg_has("bridge.%s.port", dpif_name)) {
|
|| !cfg_has("bridge.%s.port", dpif_name)) {
|
||||||
dpif_delete(&dpif);
|
dpif_delete(dpif);
|
||||||
}
|
}
|
||||||
dpif_close(&dpif);
|
dpif_close(dpif);
|
||||||
} else if (retval != ENODEV) {
|
} else if (retval != ENODEV) {
|
||||||
VLOG_ERR("failed to delete datapath dp%d: %s",
|
VLOG_ERR("failed to delete datapath dp%d: %s",
|
||||||
i, strerror(retval));
|
i, strerror(retval));
|
||||||
@@ -418,16 +418,16 @@ bridge_reconfigure(void)
|
|||||||
size_t n_dpif_ports;
|
size_t n_dpif_ports;
|
||||||
struct svec want_ifaces;
|
struct svec want_ifaces;
|
||||||
|
|
||||||
dpif_port_list(&br->dpif, &dpif_ports, &n_dpif_ports);
|
dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
|
||||||
bridge_get_all_ifaces(br, &want_ifaces);
|
bridge_get_all_ifaces(br, &want_ifaces);
|
||||||
for (i = 0; i < n_dpif_ports; i++) {
|
for (i = 0; i < n_dpif_ports; i++) {
|
||||||
const struct odp_port *p = &dpif_ports[i];
|
const struct odp_port *p = &dpif_ports[i];
|
||||||
if (!svec_contains(&want_ifaces, p->devname)
|
if (!svec_contains(&want_ifaces, p->devname)
|
||||||
&& strcmp(p->devname, br->name)) {
|
&& strcmp(p->devname, br->name)) {
|
||||||
int retval = dpif_port_del(&br->dpif, p->port);
|
int retval = dpif_port_del(br->dpif, p->port);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
VLOG_ERR("failed to remove %s interface from %s: %s",
|
VLOG_ERR("failed to remove %s interface from %s: %s",
|
||||||
p->devname, dpif_name(&br->dpif),
|
p->devname, dpif_name(br->dpif),
|
||||||
strerror(retval));
|
strerror(retval));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ bridge_reconfigure(void)
|
|||||||
struct svec cur_ifaces, want_ifaces, add_ifaces;
|
struct svec cur_ifaces, want_ifaces, add_ifaces;
|
||||||
int next_port_no;
|
int next_port_no;
|
||||||
|
|
||||||
dpif_port_list(&br->dpif, &dpif_ports, &n_dpif_ports);
|
dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
|
||||||
svec_init(&cur_ifaces);
|
svec_init(&cur_ifaces);
|
||||||
for (i = 0; i < n_dpif_ports; i++) {
|
for (i = 0; i < n_dpif_ports; i++) {
|
||||||
svec_add(&cur_ifaces, dpif_ports[i].devname);
|
svec_add(&cur_ifaces, dpif_ports[i].devname);
|
||||||
@@ -456,17 +456,17 @@ bridge_reconfigure(void)
|
|||||||
const char *if_name = add_ifaces.names[i];
|
const char *if_name = add_ifaces.names[i];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int internal = cfg_get_bool(0, "iface.%s.internal", if_name);
|
int internal = cfg_get_bool(0, "iface.%s.internal", if_name);
|
||||||
int error = dpif_port_add(&br->dpif, if_name, next_port_no++,
|
int error = dpif_port_add(br->dpif, if_name, next_port_no++,
|
||||||
internal ? ODP_PORT_INTERNAL : 0);
|
internal ? ODP_PORT_INTERNAL : 0);
|
||||||
if (error != EEXIST) {
|
if (error != EEXIST) {
|
||||||
if (next_port_no >= 256) {
|
if (next_port_no >= 256) {
|
||||||
VLOG_ERR("ran out of valid port numbers on %s",
|
VLOG_ERR("ran out of valid port numbers on %s",
|
||||||
dpif_name(&br->dpif));
|
dpif_name(br->dpif));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
VLOG_ERR("failed to add %s interface to %s: %s",
|
VLOG_ERR("failed to add %s interface to %s: %s",
|
||||||
if_name, dpif_name(&br->dpif),
|
if_name, dpif_name(br->dpif),
|
||||||
strerror(error));
|
strerror(error));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -495,14 +495,14 @@ bridge_reconfigure(void)
|
|||||||
struct iface *iface = port->ifaces[j];
|
struct iface *iface = port->ifaces[j];
|
||||||
if (iface->dp_ifidx < 0) {
|
if (iface->dp_ifidx < 0) {
|
||||||
VLOG_ERR("%s interface not in %s, dropping",
|
VLOG_ERR("%s interface not in %s, dropping",
|
||||||
iface->name, dpif_name(&br->dpif));
|
iface->name, dpif_name(br->dpif));
|
||||||
iface_destroy(iface);
|
iface_destroy(iface);
|
||||||
} else {
|
} else {
|
||||||
if (iface->dp_ifidx == ODPP_LOCAL) {
|
if (iface->dp_ifidx == ODPP_LOCAL) {
|
||||||
local_iface = iface;
|
local_iface = iface;
|
||||||
}
|
}
|
||||||
VLOG_DBG("%s has interface %s on port %d",
|
VLOG_DBG("%s has interface %s on port %d",
|
||||||
dpif_name(&br->dpif),
|
dpif_name(br->dpif),
|
||||||
iface->name, iface->dp_ifidx);
|
iface->name, iface->dp_ifidx);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -531,7 +531,7 @@ bridge_reconfigure(void)
|
|||||||
ofproto_set_datapath_id(br->ofproto, dpid);
|
ofproto_set_datapath_id(br->ofproto, dpid);
|
||||||
|
|
||||||
/* Set NetFlow configuration on this bridge. */
|
/* Set NetFlow configuration on this bridge. */
|
||||||
dpif_get_netflow_ids(&br->dpif, &engine_type, &engine_id);
|
dpif_get_netflow_ids(br->dpif, &engine_type, &engine_id);
|
||||||
if (cfg_has("netflow.%s.engine-type", br->name)) {
|
if (cfg_has("netflow.%s.engine-type", br->name)) {
|
||||||
engine_type = cfg_get_int(0, "netflow.%s.engine-type",
|
engine_type = cfg_get_int(0, "netflow.%s.engine-type",
|
||||||
br->name);
|
br->name);
|
||||||
@@ -812,7 +812,7 @@ bridge_create(const char *name)
|
|||||||
free(br);
|
free(br);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dpif_flow_flush(&br->dpif);
|
dpif_flow_flush(br->dpif);
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
VLOG_ERR("failed to create datapath %s: %s", name, strerror(error));
|
VLOG_ERR("failed to create datapath %s: %s", name, strerror(error));
|
||||||
free(br);
|
free(br);
|
||||||
@@ -822,8 +822,8 @@ bridge_create(const char *name)
|
|||||||
error = ofproto_create(name, &bridge_ofhooks, br, &br->ofproto);
|
error = ofproto_create(name, &bridge_ofhooks, br, &br->ofproto);
|
||||||
if (error) {
|
if (error) {
|
||||||
VLOG_ERR("failed to create switch %s: %s", name, strerror(error));
|
VLOG_ERR("failed to create switch %s: %s", name, strerror(error));
|
||||||
dpif_delete(&br->dpif);
|
dpif_delete(br->dpif);
|
||||||
dpif_close(&br->dpif);
|
dpif_close(br->dpif);
|
||||||
free(br);
|
free(br);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -840,7 +840,7 @@ bridge_create(const char *name)
|
|||||||
|
|
||||||
list_push_back(&all_bridges, &br->node);
|
list_push_back(&all_bridges, &br->node);
|
||||||
|
|
||||||
VLOG_INFO("created bridge %s on %s", br->name, dpif_name(&br->dpif));
|
VLOG_INFO("created bridge %s on %s", br->name, dpif_name(br->dpif));
|
||||||
|
|
||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
@@ -855,12 +855,12 @@ bridge_destroy(struct bridge *br)
|
|||||||
port_destroy(br->ports[br->n_ports - 1]);
|
port_destroy(br->ports[br->n_ports - 1]);
|
||||||
}
|
}
|
||||||
list_remove(&br->node);
|
list_remove(&br->node);
|
||||||
error = dpif_delete(&br->dpif);
|
error = dpif_delete(br->dpif);
|
||||||
if (error && error != ENOENT) {
|
if (error && error != ENOENT) {
|
||||||
VLOG_ERR("failed to delete %s: %s",
|
VLOG_ERR("failed to delete %s: %s",
|
||||||
dpif_name(&br->dpif), strerror(error));
|
dpif_name(br->dpif), strerror(error));
|
||||||
}
|
}
|
||||||
dpif_close(&br->dpif);
|
dpif_close(br->dpif);
|
||||||
ofproto_destroy(br->ofproto);
|
ofproto_destroy(br->ofproto);
|
||||||
free(br->controller);
|
free(br->controller);
|
||||||
mac_learning_destroy(br->ml);
|
mac_learning_destroy(br->ml);
|
||||||
@@ -1248,17 +1248,17 @@ bridge_fetch_dp_ifaces(struct bridge *br)
|
|||||||
}
|
}
|
||||||
port_array_clear(&br->ifaces);
|
port_array_clear(&br->ifaces);
|
||||||
|
|
||||||
dpif_port_list(&br->dpif, &dpif_ports, &n_dpif_ports);
|
dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
|
||||||
for (i = 0; i < n_dpif_ports; i++) {
|
for (i = 0; i < n_dpif_ports; i++) {
|
||||||
struct odp_port *p = &dpif_ports[i];
|
struct odp_port *p = &dpif_ports[i];
|
||||||
struct iface *iface = iface_lookup(br, p->devname);
|
struct iface *iface = iface_lookup(br, p->devname);
|
||||||
if (iface) {
|
if (iface) {
|
||||||
if (iface->dp_ifidx >= 0) {
|
if (iface->dp_ifidx >= 0) {
|
||||||
VLOG_WARN("%s reported interface %s twice",
|
VLOG_WARN("%s reported interface %s twice",
|
||||||
dpif_name(&br->dpif), p->devname);
|
dpif_name(br->dpif), p->devname);
|
||||||
} else if (iface_from_dp_ifidx(br, p->port)) {
|
} else if (iface_from_dp_ifidx(br, p->port)) {
|
||||||
VLOG_WARN("%s reported interface %"PRIu16" twice",
|
VLOG_WARN("%s reported interface %"PRIu16" twice",
|
||||||
dpif_name(&br->dpif), p->port);
|
dpif_name(br->dpif), p->port);
|
||||||
} else {
|
} else {
|
||||||
port_array_set(&br->ifaces, p->port, iface);
|
port_array_set(&br->ifaces, p->port, iface);
|
||||||
iface->dp_ifidx = p->port;
|
iface->dp_ifidx = p->port;
|
||||||
|
Reference in New Issue
Block a user