mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 14:55:18 +00:00
netdev-linux: Rename "linux_netdev_*" to "rtnetlink_*".
It was getting to be too confusing to have both netdev_linux_* functions and linux_netdev_* functions. Rename the latter to make the distinction more obvious. "rtnetlink" seems to be a fairly good name because that's what the kernel calls it, so the name will be familiar at least to people who know about rtnetlink.
This commit is contained in:
@@ -52,7 +52,7 @@ struct dpif_linux {
|
|||||||
/* Change notification. */
|
/* Change notification. */
|
||||||
int local_ifindex; /* Ifindex of local port. */
|
int local_ifindex; /* Ifindex of local port. */
|
||||||
struct svec changed_ports; /* Ports that have changed. */
|
struct svec changed_ports; /* Ports that have changed. */
|
||||||
struct linux_netdev_notifier port_notifier;
|
struct rtnetlink_notifier port_notifier;
|
||||||
bool change_error;
|
bool change_error;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ static int finish_open(struct dpif *, const char *local_ifname);
|
|||||||
static int create_minor(const char *name, int minor, struct dpif **dpifp);
|
static int create_minor(const char *name, int minor, struct dpif **dpifp);
|
||||||
static int open_minor(int minor, struct dpif **dpifp);
|
static int open_minor(int minor, struct dpif **dpifp);
|
||||||
static int make_openvswitch_device(int minor, char **fnp);
|
static int make_openvswitch_device(int minor, char **fnp);
|
||||||
static void dpif_linux_port_changed(const struct linux_netdev_change *,
|
static void dpif_linux_port_changed(const struct rtnetlink_change *,
|
||||||
void *dpif);
|
void *dpif);
|
||||||
|
|
||||||
static struct dpif_linux *
|
static struct dpif_linux *
|
||||||
@@ -161,7 +161,7 @@ static void
|
|||||||
dpif_linux_close(struct dpif *dpif_)
|
dpif_linux_close(struct dpif *dpif_)
|
||||||
{
|
{
|
||||||
struct dpif_linux *dpif = dpif_linux_cast(dpif_);
|
struct dpif_linux *dpif = dpif_linux_cast(dpif_);
|
||||||
linux_netdev_notifier_unregister(&dpif->port_notifier);
|
rtnetlink_notifier_unregister(&dpif->port_notifier);
|
||||||
svec_destroy(&dpif->changed_ports);
|
svec_destroy(&dpif->changed_ports);
|
||||||
free(dpif->local_ifname);
|
free(dpif->local_ifname);
|
||||||
close(dpif->fd);
|
close(dpif->fd);
|
||||||
@@ -294,7 +294,7 @@ dpif_linux_port_poll_wait(const struct dpif *dpif_)
|
|||||||
if (dpif->changed_ports.n || dpif->change_error) {
|
if (dpif->changed_ports.n || dpif->change_error) {
|
||||||
poll_immediate_wake();
|
poll_immediate_wake();
|
||||||
} else {
|
} else {
|
||||||
linux_netdev_notifier_wait();
|
rtnetlink_notifier_wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -698,8 +698,8 @@ open_minor(int minor, struct dpif **dpifp)
|
|||||||
fd = open(fn, O_RDONLY | O_NONBLOCK);
|
fd = open(fn, O_RDONLY | O_NONBLOCK);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
struct dpif_linux *dpif = xmalloc(sizeof *dpif);
|
struct dpif_linux *dpif = xmalloc(sizeof *dpif);
|
||||||
error = linux_netdev_notifier_register(&dpif->port_notifier,
|
error = rtnetlink_notifier_register(&dpif->port_notifier,
|
||||||
dpif_linux_port_changed, dpif);
|
dpif_linux_port_changed, dpif);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
@@ -727,7 +727,7 @@ open_minor(int minor, struct dpif **dpifp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dpif_linux_port_changed(const struct linux_netdev_change *change, void *dpif_)
|
dpif_linux_port_changed(const struct rtnetlink_change *change, void *dpif_)
|
||||||
{
|
{
|
||||||
struct dpif_linux *dpif = dpif_;
|
struct dpif_linux *dpif = dpif_;
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ struct netdev_linux_cache {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct shash cache_map = SHASH_INITIALIZER(&cache_map);
|
static struct shash cache_map = SHASH_INITIALIZER(&cache_map);
|
||||||
static struct linux_netdev_notifier netdev_linux_cache_notifier;
|
static struct rtnetlink_notifier netdev_linux_cache_notifier;
|
||||||
|
|
||||||
/* Policy for RTNLGRP_LINK messages.
|
/* Policy for RTNLGRP_LINK messages.
|
||||||
*
|
*
|
||||||
@@ -128,7 +128,7 @@ struct netdev_linux_notifier {
|
|||||||
|
|
||||||
static struct shash netdev_linux_notifiers =
|
static struct shash netdev_linux_notifiers =
|
||||||
SHASH_INITIALIZER(&netdev_linux_notifiers);
|
SHASH_INITIALIZER(&netdev_linux_notifiers);
|
||||||
static struct linux_netdev_notifier netdev_linux_poll_notifier;
|
static struct rtnetlink_notifier netdev_linux_poll_notifier;
|
||||||
|
|
||||||
/* This is set pretty low because we probably won't learn anything from the
|
/* This is set pretty low because we probably won't learn anything from the
|
||||||
* additional log messages. */
|
* additional log messages. */
|
||||||
@@ -175,17 +175,17 @@ netdev_linux_init(void)
|
|||||||
static void
|
static void
|
||||||
netdev_linux_run(void)
|
netdev_linux_run(void)
|
||||||
{
|
{
|
||||||
linux_netdev_notifier_run();
|
rtnetlink_notifier_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
netdev_linux_wait(void)
|
netdev_linux_wait(void)
|
||||||
{
|
{
|
||||||
linux_netdev_notifier_wait();
|
rtnetlink_notifier_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
netdev_linux_cache_cb(const struct linux_netdev_change *change,
|
netdev_linux_cache_cb(const struct rtnetlink_change *change,
|
||||||
void *aux UNUSED)
|
void *aux UNUSED)
|
||||||
{
|
{
|
||||||
struct netdev_linux_cache *cache;
|
struct netdev_linux_cache *cache;
|
||||||
@@ -219,7 +219,7 @@ netdev_linux_open(const char *name, char *suffix, int ethertype,
|
|||||||
netdev->cache = shash_find_data(&cache_map, suffix);
|
netdev->cache = shash_find_data(&cache_map, suffix);
|
||||||
if (!netdev->cache) {
|
if (!netdev->cache) {
|
||||||
if (shash_is_empty(&cache_map)) {
|
if (shash_is_empty(&cache_map)) {
|
||||||
int error = linux_netdev_notifier_register(
|
int error = rtnetlink_notifier_register(
|
||||||
&netdev_linux_cache_notifier, netdev_linux_cache_cb, NULL);
|
&netdev_linux_cache_notifier, netdev_linux_cache_cb, NULL);
|
||||||
if (error) {
|
if (error) {
|
||||||
netdev_close(&netdev->netdev);
|
netdev_close(&netdev->netdev);
|
||||||
@@ -336,7 +336,7 @@ netdev_linux_close(struct netdev *netdev_)
|
|||||||
free(netdev->cache);
|
free(netdev->cache);
|
||||||
|
|
||||||
if (shash_is_empty(&cache_map)) {
|
if (shash_is_empty(&cache_map)) {
|
||||||
linux_netdev_notifier_unregister(&netdev_linux_cache_notifier);
|
rtnetlink_notifier_unregister(&netdev_linux_cache_notifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (netdev->netdev_fd >= 0) {
|
if (netdev->netdev_fd >= 0) {
|
||||||
@@ -1175,7 +1175,7 @@ poll_notify(struct list *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
netdev_linux_poll_cb(const struct linux_netdev_change *change,
|
netdev_linux_poll_cb(const struct rtnetlink_change *change,
|
||||||
void *aux UNUSED)
|
void *aux UNUSED)
|
||||||
{
|
{
|
||||||
if (change) {
|
if (change) {
|
||||||
@@ -1202,7 +1202,7 @@ netdev_linux_poll_add(struct netdev *netdev,
|
|||||||
struct list *list;
|
struct list *list;
|
||||||
|
|
||||||
if (shash_is_empty(&netdev_linux_notifiers)) {
|
if (shash_is_empty(&netdev_linux_notifiers)) {
|
||||||
int error = linux_netdev_notifier_register(&netdev_linux_poll_notifier,
|
int error = rtnetlink_notifier_register(&netdev_linux_poll_notifier,
|
||||||
netdev_linux_poll_cb, NULL);
|
netdev_linux_poll_cb, NULL);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
@@ -1243,7 +1243,7 @@ netdev_linux_poll_remove(struct netdev_notifier *notifier_)
|
|||||||
|
|
||||||
/* If that was the last notifier, unregister. */
|
/* If that was the last notifier, unregister. */
|
||||||
if (shash_is_empty(&netdev_linux_notifiers)) {
|
if (shash_is_empty(&netdev_linux_notifiers)) {
|
||||||
linux_netdev_notifier_unregister(&netdev_linux_poll_notifier);
|
rtnetlink_notifier_unregister(&netdev_linux_poll_notifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1600,14 +1600,14 @@ static struct nl_sock *notify_sock;
|
|||||||
/* All registered notifiers. */
|
/* All registered notifiers. */
|
||||||
static struct list all_notifiers = LIST_INITIALIZER(&all_notifiers);
|
static struct list all_notifiers = LIST_INITIALIZER(&all_notifiers);
|
||||||
|
|
||||||
static void linux_netdev_report_change(const struct nlmsghdr *,
|
static void rtnetlink_report_change(const struct nlmsghdr *,
|
||||||
const struct ifinfomsg *,
|
const struct ifinfomsg *,
|
||||||
struct nlattr *attrs[]);
|
struct nlattr *attrs[]);
|
||||||
static void linux_netdev_report_notify_error(void);
|
static void rtnetlink_report_notify_error(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
linux_netdev_notifier_register(struct linux_netdev_notifier *notifier,
|
rtnetlink_notifier_register(struct rtnetlink_notifier *notifier,
|
||||||
linux_netdev_notify_func *cb, void *aux)
|
rtnetlink_notify_func *cb, void *aux)
|
||||||
{
|
{
|
||||||
if (!notify_sock) {
|
if (!notify_sock) {
|
||||||
int error = nl_sock_create(NETLINK_ROUTE, RTNLGRP_LINK, 0, 0,
|
int error = nl_sock_create(NETLINK_ROUTE, RTNLGRP_LINK, 0, 0,
|
||||||
@@ -1620,7 +1620,7 @@ linux_netdev_notifier_register(struct linux_netdev_notifier *notifier,
|
|||||||
} else {
|
} else {
|
||||||
/* Catch up on notification work so that the new notifier won't
|
/* Catch up on notification work so that the new notifier won't
|
||||||
* receive any stale notifications. */
|
* receive any stale notifications. */
|
||||||
linux_netdev_notifier_run();
|
rtnetlink_notifier_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
list_push_back(&all_notifiers, ¬ifier->node);
|
list_push_back(&all_notifiers, ¬ifier->node);
|
||||||
@@ -1630,7 +1630,7 @@ linux_netdev_notifier_register(struct linux_netdev_notifier *notifier,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
linux_netdev_notifier_unregister(struct linux_netdev_notifier *notifier)
|
rtnetlink_notifier_unregister(struct rtnetlink_notifier *notifier)
|
||||||
{
|
{
|
||||||
list_remove(¬ifier->node);
|
list_remove(¬ifier->node);
|
||||||
if (list_is_empty(&all_notifiers)) {
|
if (list_is_empty(&all_notifiers)) {
|
||||||
@@ -1640,7 +1640,7 @@ linux_netdev_notifier_unregister(struct linux_netdev_notifier *notifier)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
linux_netdev_notifier_run(void)
|
rtnetlink_notifier_run(void)
|
||||||
{
|
{
|
||||||
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
||||||
|
|
||||||
@@ -1661,10 +1661,10 @@ linux_netdev_notifier_run(void)
|
|||||||
struct ifinfomsg *ifinfo;
|
struct ifinfomsg *ifinfo;
|
||||||
|
|
||||||
ifinfo = (void *) ((char *) buf->data + NLMSG_HDRLEN);
|
ifinfo = (void *) ((char *) buf->data + NLMSG_HDRLEN);
|
||||||
linux_netdev_report_change(buf->data, ifinfo, attrs);
|
rtnetlink_report_change(buf->data, ifinfo, attrs);
|
||||||
} else {
|
} else {
|
||||||
VLOG_WARN_RL(&rl, "received bad rtnl message");
|
VLOG_WARN_RL(&rl, "received bad rtnl message");
|
||||||
linux_netdev_report_notify_error();
|
rtnetlink_report_notify_error();
|
||||||
}
|
}
|
||||||
ofpbuf_delete(buf);
|
ofpbuf_delete(buf);
|
||||||
} else if (error == EAGAIN) {
|
} else if (error == EAGAIN) {
|
||||||
@@ -1676,13 +1676,13 @@ linux_netdev_notifier_run(void)
|
|||||||
VLOG_WARN_RL(&rl, "error reading rtnetlink socket: %s",
|
VLOG_WARN_RL(&rl, "error reading rtnetlink socket: %s",
|
||||||
strerror(error));
|
strerror(error));
|
||||||
}
|
}
|
||||||
linux_netdev_report_notify_error();
|
rtnetlink_report_notify_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
linux_netdev_notifier_wait(void)
|
rtnetlink_notifier_wait(void)
|
||||||
{
|
{
|
||||||
if (notify_sock) {
|
if (notify_sock) {
|
||||||
nl_sock_wait(notify_sock, POLLIN);
|
nl_sock_wait(notify_sock, POLLIN);
|
||||||
@@ -1690,14 +1690,14 @@ linux_netdev_notifier_wait(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
linux_netdev_report_change(const struct nlmsghdr *nlmsg,
|
rtnetlink_report_change(const struct nlmsghdr *nlmsg,
|
||||||
const struct ifinfomsg *ifinfo,
|
const struct ifinfomsg *ifinfo,
|
||||||
struct nlattr *attrs[])
|
struct nlattr *attrs[])
|
||||||
{
|
{
|
||||||
struct linux_netdev_notifier *notifier;
|
struct rtnetlink_notifier *notifier;
|
||||||
struct linux_netdev_change change;
|
struct rtnetlink_change change;
|
||||||
|
|
||||||
COVERAGE_INC(linux_netdev_changed);
|
COVERAGE_INC(rtnetlink_changed);
|
||||||
|
|
||||||
change.nlmsg_type = nlmsg->nlmsg_type;
|
change.nlmsg_type = nlmsg->nlmsg_type;
|
||||||
change.ifi_index = ifinfo->ifi_index;
|
change.ifi_index = ifinfo->ifi_index;
|
||||||
@@ -1705,18 +1705,18 @@ linux_netdev_report_change(const struct nlmsghdr *nlmsg,
|
|||||||
change.master_ifindex = (attrs[IFLA_MASTER]
|
change.master_ifindex = (attrs[IFLA_MASTER]
|
||||||
? nl_attr_get_u32(attrs[IFLA_MASTER]) : 0);
|
? nl_attr_get_u32(attrs[IFLA_MASTER]) : 0);
|
||||||
|
|
||||||
LIST_FOR_EACH (notifier, struct linux_netdev_notifier, node,
|
LIST_FOR_EACH (notifier, struct rtnetlink_notifier, node,
|
||||||
&all_notifiers) {
|
&all_notifiers) {
|
||||||
notifier->cb(&change, notifier->aux);
|
notifier->cb(&change, notifier->aux);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
linux_netdev_report_notify_error(void)
|
rtnetlink_report_notify_error(void)
|
||||||
{
|
{
|
||||||
struct linux_netdev_notifier *notifier;
|
struct rtnetlink_notifier *notifier;
|
||||||
|
|
||||||
LIST_FOR_EACH (notifier, struct linux_netdev_notifier, node,
|
LIST_FOR_EACH (notifier, struct rtnetlink_notifier, node,
|
||||||
&all_notifiers) {
|
&all_notifiers) {
|
||||||
notifier->cb(NULL, notifier->aux);
|
notifier->cb(NULL, notifier->aux);
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
struct linux_netdev_change {
|
struct rtnetlink_change {
|
||||||
/* Copied from struct nlmsghdr. */
|
/* Copied from struct nlmsghdr. */
|
||||||
int nlmsg_type; /* e.g. RTM_NEWLINK, RTM_DELLINK. */
|
int nlmsg_type; /* e.g. RTM_NEWLINK, RTM_DELLINK. */
|
||||||
|
|
||||||
@@ -34,19 +34,19 @@ struct linux_netdev_change {
|
|||||||
int master_ifindex; /* Ifindex of datapath master (0 if none). */
|
int master_ifindex; /* Ifindex of datapath master (0 if none). */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void linux_netdev_notify_func(const struct linux_netdev_change *,
|
typedef void rtnetlink_notify_func(const struct rtnetlink_change *,
|
||||||
void *aux);
|
void *aux);
|
||||||
|
|
||||||
struct linux_netdev_notifier {
|
struct rtnetlink_notifier {
|
||||||
struct list node;
|
struct list node;
|
||||||
linux_netdev_notify_func *cb;
|
rtnetlink_notify_func *cb;
|
||||||
void *aux;
|
void *aux;
|
||||||
};
|
};
|
||||||
|
|
||||||
int linux_netdev_notifier_register(struct linux_netdev_notifier *,
|
int rtnetlink_notifier_register(struct rtnetlink_notifier *,
|
||||||
linux_netdev_notify_func *, void *aux);
|
rtnetlink_notify_func *, void *aux);
|
||||||
void linux_netdev_notifier_unregister(struct linux_netdev_notifier *);
|
void rtnetlink_notifier_unregister(struct rtnetlink_notifier *);
|
||||||
void linux_netdev_notifier_run(void);
|
void rtnetlink_notifier_run(void);
|
||||||
void linux_netdev_notifier_wait(void);
|
void rtnetlink_notifier_wait(void);
|
||||||
|
|
||||||
#endif /* netdev-linux.h */
|
#endif /* netdev-linux.h */
|
||||||
|
Reference in New Issue
Block a user