Skip to content

Commit

Permalink
route-table: Remove Unregister.
Browse files Browse the repository at this point in the history
Since dpif registering for routing table at initialization
there is no need to unregister it. Following patch removes
support for turning routing table notifications on and off.
Due to this change OVS always listens for these
notifications.

Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
  • Loading branch information
Pravin B Shelar committed Dec 1, 2014
1 parent 36fd4f2 commit b772066
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 70 deletions.
2 changes: 1 addition & 1 deletion lib/dpif.c
Expand Up @@ -120,7 +120,7 @@ dp_initialize(void)
dpctl_unixctl_register();
tnl_port_map_init();
tnl_arp_cache_init();
route_table_register();
route_table_init();

for (i = 0; i < ARRAY_SIZE(base_dpif_classes); i++) {
dp_register_provider(base_dpif_classes[i]);
Expand Down
1 change: 0 additions & 1 deletion lib/netdev-vport.c
Expand Up @@ -262,7 +262,6 @@ netdev_vport_destruct(struct netdev *netdev_)
{
struct netdev_vport *netdev = netdev_vport_cast(netdev_);

route_table_unregister();
free(netdev->peer);
ovs_mutex_destroy(&netdev->mutex);
}
Expand Down
16 changes: 2 additions & 14 deletions lib/route-table-bsd.c
Expand Up @@ -33,7 +33,6 @@
#include "util.h"

static int pid;
static unsigned int register_count = 0;

bool
ovs_router_lookup(ovs_be32 ip, char name[], ovs_be32 *gw)
Expand Down Expand Up @@ -116,20 +115,9 @@ route_table_get_change_seq(void)
}

void
route_table_register(void)
route_table_init(void)
{
if (!register_count)
{
pid = getpid();
}

register_count++;
}

void
route_table_unregister(void)
{
register_count--;
pid = getpid();
}

void
Expand Down
7 changes: 1 addition & 6 deletions lib/route-table-stub.c
Expand Up @@ -38,12 +38,7 @@ route_table_get_change_seq(void)
}

void
route_table_register(void)
{
}

void
route_table_unregister(void)
route_table_init(void)
{
}

Expand Down
55 changes: 11 additions & 44 deletions lib/route-table.c
Expand Up @@ -61,7 +61,6 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
* every time route_table_reset() is called. */
static uint64_t rt_change_seq;

static unsigned int register_count = 0;
static struct nln *nln = NULL;
static struct route_table_msg rtmsg;
static struct nln_notifier *route_notifier = NULL;
Expand All @@ -76,7 +75,6 @@ static void route_table_change(const struct route_table_msg *, void *);
static void route_map_clear(void);

static void name_table_init(void);
static void name_table_uninit(void);
static void name_table_change(const struct rtnetlink_link_change *, void *);

uint64_t
Expand All @@ -88,49 +86,24 @@ route_table_get_change_seq(void)
/* Users of the route_table module should register themselves with this
* function before making any other route_table function calls. */
void
route_table_register(void)
route_table_init(void)
OVS_EXCLUDED(route_table_mutex)
{
ovs_mutex_lock(&route_table_mutex);
if (!register_count) {
ovs_assert(!nln);
ovs_assert(!route_notifier);
ovs_assert(!nln);
ovs_assert(!route_notifier);

ovs_router_init();
nln = nln_create(NETLINK_ROUTE, RTNLGRP_IPV4_ROUTE,
(nln_parse_func *) route_table_parse, &rtmsg);
ovs_router_init();
nln = nln_create(NETLINK_ROUTE, RTNLGRP_IPV4_ROUTE,
(nln_parse_func *) route_table_parse, &rtmsg);

route_notifier =
nln_notifier_create(nln, (nln_notify_func *) route_table_change,
NULL);
route_notifier =
nln_notifier_create(nln, (nln_notify_func *) route_table_change,
NULL);

route_table_reset();
name_table_init();
}

register_count++;
ovs_mutex_unlock(&route_table_mutex);
}

/* Users of the route_table module should unregister themselves with this
* function when they will no longer be making any more route_table fuction
* calls. */
void
route_table_unregister(void)
OVS_EXCLUDED(route_table_mutex)
{
ovs_mutex_lock(&route_table_mutex);
register_count--;
route_table_reset();
name_table_init();

if (!register_count) {
nln_notifier_destroy(route_notifier);
route_notifier = NULL;
nln_destroy(nln);
nln = NULL;

route_map_clear();
name_table_uninit();
}
ovs_mutex_unlock(&route_table_mutex);
}

Expand Down Expand Up @@ -300,12 +273,6 @@ name_table_init(void)
name_notifier = rtnetlink_link_notifier_create(name_table_change, NULL);
}

static void
name_table_uninit(void)
{
rtnetlink_link_notifier_destroy(name_notifier);
name_notifier = NULL;
}

static void
name_table_change(const struct rtnetlink_link_change *change OVS_UNUSED,
Expand Down
3 changes: 1 addition & 2 deletions lib/route-table.h
Expand Up @@ -26,8 +26,7 @@
#include "openvswitch/types.h"

uint64_t route_table_get_change_seq(void);
void route_table_register(void);
void route_table_unregister(void);
void route_table_init(void);
void route_table_run(void);
void route_table_wait(void);

Expand Down
2 changes: 0 additions & 2 deletions ofproto/ofproto-dpif-sflow.c
Expand Up @@ -390,7 +390,6 @@ dpif_sflow_create(void)
ds->next_tick = time_now() + 1;
hmap_init(&ds->ports);
ds->probability = 0;
route_table_register();
ovs_refcount_init(&ds->ref_cnt);

return ds;
Expand Down Expand Up @@ -425,7 +424,6 @@ dpif_sflow_unref(struct dpif_sflow *ds) OVS_EXCLUDED(mutex)
if (ds && ovs_refcount_unref_relaxed(&ds->ref_cnt) == 1) {
struct dpif_sflow_port *dsp, *next;

route_table_unregister();
dpif_sflow_clear(ds);
HMAP_FOR_EACH_SAFE (dsp, next, hmap_node, &ds->ports) {
dpif_sflow_del_port__(ds, dsp);
Expand Down

0 comments on commit b772066

Please sign in to comment.