Skip to content

Commit

Permalink
use async multicast msg for route/route6/svc/dest setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ywc689 committed Jan 16, 2020
1 parent 1d7ce44 commit 329c78b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
11 changes: 9 additions & 2 deletions src/ipv6/route6.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ struct rt6_dustbin {
static int g_rt6_recycle_time = RT6_RECYCLE_TIME_DEF;
static RTE_DEFINE_PER_LCORE(struct rt6_dustbin, rt6_dbin);

static int rt6_msg_seq(void)
{
static uint32_t seq = 0;

return seq++;
}

static inline void rt6_zero_prefix_tail(struct rt6_prefix *rt6_p)
{
struct in6_addr addr6;
Expand Down Expand Up @@ -227,15 +234,15 @@ static int rt6_add_del(const struct dp_vs_route6_conf *cf)
}

/* for slaves */
msg = msg_make(MSG_TYPE_ROUTE6, 0, DPVS_MSG_MULTICAST, cid,
msg = msg_make(MSG_TYPE_ROUTE6, rt6_msg_seq(), DPVS_MSG_MULTICAST, cid,
sizeof(struct dp_vs_route6_conf), cf);
if (unlikely(msg == NULL)) {
RTE_LOG(ERR, RT6, "%s: fail to add/del route on slaves -- %s\n",
__func__, dpvs_strerror(err));
return EDPVS_NOMEM;
}

err = multicast_msg_send(msg, 0, NULL);
err = multicast_msg_send(msg, DPVS_MSG_F_ASYNC, NULL);
if (err != EDPVS_OK)
RTE_LOG(WARNING, RT6, "%s: multicast_msg_send failed -- %s\n",
__func__, dpvs_strerror(err));
Expand Down
9 changes: 8 additions & 1 deletion src/ipvs/ip_vs_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,13 @@ static inline int set_opt_so2msg(sockoptid_t opt)
return opt - SOCKOPT_SVC_BASE + MSG_TYPE_SVC_SET_BASE;
}

static int svc_msg_seq(void)
{
static uint32_t seq = 0;

return seq++;
}

static int dp_vs_set_svc(sockoptid_t opt, const void *user, size_t len)
{
int ret;
Expand All @@ -925,7 +932,7 @@ static int dp_vs_set_svc(sockoptid_t opt, const void *user, size_t len)
if (cid == rte_get_master_lcore()) {
struct dpvs_msg *msg;

msg = msg_make(set_opt_so2msg(opt), 0, DPVS_MSG_MULTICAST, cid, len, user);
msg = msg_make(set_opt_so2msg(opt), svc_msg_seq(), DPVS_MSG_MULTICAST, cid, len, user);
if (!msg)
return EDPVS_NOMEM;

Expand Down
19 changes: 11 additions & 8 deletions src/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ static RTE_DEFINE_PER_LCORE(struct route_lcore, route_lcore);
static RTE_DEFINE_PER_LCORE(rte_atomic32_t, num_routes);
static RTE_DEFINE_PER_LCORE(rte_atomic32_t, num_out_routes);

static int route_msg_seq(void)
{
static uint32_t seq = 0;

return seq++;
}

static inline bool net_cmp(const struct netif_port *port, uint32_t dest,
uint8_t mask, const struct route_entry *route_node)
{
Expand Down Expand Up @@ -370,20 +377,16 @@ static int route_add_del(bool add, struct in_addr* dest,
cf.metric = metric;

if (add)
msg = msg_make(MSG_TYPE_ROUTE_ADD, 0, DPVS_MSG_MULTICAST,
msg = msg_make(MSG_TYPE_ROUTE_ADD, route_msg_seq(), DPVS_MSG_MULTICAST,
cid, sizeof(struct dp_vs_route_conf), &cf);
else
msg = msg_make(MSG_TYPE_ROUTE_DEL, 0, DPVS_MSG_MULTICAST,
msg = msg_make(MSG_TYPE_ROUTE_DEL, route_msg_seq(), DPVS_MSG_MULTICAST,
cid, sizeof(struct dp_vs_route_conf), &cf);

err = multicast_msg_send(msg, 0/*DPVS_MSG_F_ASYNC*/, NULL);
if (err != EDPVS_OK) {
/* ignore timeout for msg, or keepalived will cause a lot bug.
* Timeout error is ok because route can still be set,
* no mem is another possible err, but problem will not just be here */
err = multicast_msg_send(msg, DPVS_MSG_F_ASYNC, NULL);
if (err != EDPVS_OK)
RTE_LOG(INFO, ROUTE, "[%s] fail to send multicast message, error code = %d\n",
__func__, err);
}
msg_destroy(&msg);

return EDPVS_OK;
Expand Down

0 comments on commit 329c78b

Please sign in to comment.