mirror of
https://github.com/openvswitch/ovs
synced 2025-10-25 15:07:05 +00:00
rtnetlink: Notifiers should only run once per poll loop.
rtnetlink_notifier_run() does quite a bit of work, and is likely only to have interesting effects once per poll loop.
This commit is contained in:
@@ -37,6 +37,7 @@ static void rtnetlink_report(struct rtnetlink *rtn, void *change);
|
|||||||
struct rtnetlink {
|
struct rtnetlink {
|
||||||
struct nl_sock *notify_sock; /* Rtnetlink socket. */
|
struct nl_sock *notify_sock; /* Rtnetlink socket. */
|
||||||
struct list all_notifiers; /* All rtnetlink notifiers. */
|
struct list all_notifiers; /* All rtnetlink notifiers. */
|
||||||
|
bool has_run; /* Guard for run and wait functions. */
|
||||||
|
|
||||||
/* Passed in by rtnetlink_create(). */
|
/* Passed in by rtnetlink_create(). */
|
||||||
int multicast_group; /* Multicast group we listen on. */
|
int multicast_group; /* Multicast group we listen on. */
|
||||||
@@ -59,6 +60,7 @@ rtnetlink_create(int multicast_group, rtnetlink_parse_func *parse,
|
|||||||
rtn->multicast_group = multicast_group;
|
rtn->multicast_group = multicast_group;
|
||||||
rtn->parse = parse;
|
rtn->parse = parse;
|
||||||
rtn->change = change;
|
rtn->change = change;
|
||||||
|
rtn->has_run = false;
|
||||||
|
|
||||||
list_init(&rtn->all_notifiers);
|
list_init(&rtn->all_notifiers);
|
||||||
return rtn;
|
return rtn;
|
||||||
@@ -135,10 +137,11 @@ rtnetlink_notifier_run(struct rtnetlink *rtn)
|
|||||||
{
|
{
|
||||||
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
||||||
|
|
||||||
if (!rtn->notify_sock) {
|
if (!rtn->notify_sock || rtn->has_run) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtn->has_run = true;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct ofpbuf *buf;
|
struct ofpbuf *buf;
|
||||||
int error;
|
int error;
|
||||||
@@ -170,6 +173,7 @@ rtnetlink_notifier_run(struct rtnetlink *rtn)
|
|||||||
void
|
void
|
||||||
rtnetlink_notifier_wait(struct rtnetlink *rtn)
|
rtnetlink_notifier_wait(struct rtnetlink *rtn)
|
||||||
{
|
{
|
||||||
|
rtn->has_run = false;
|
||||||
if (rtn->notify_sock) {
|
if (rtn->notify_sock) {
|
||||||
nl_sock_wait(rtn->notify_sock, POLLIN);
|
nl_sock_wait(rtn->notify_sock, POLLIN);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user