diff --git a/lcpng_netlink.c b/lcpng_netlink.c index 1dddab2..00fc86b 100644 --- a/lcpng_netlink.c +++ b/lcpng_netlink.c @@ -225,8 +225,13 @@ lcp_nl_dispatch (struct nl_object *obj, void *arg) lcp_nl_link_del ((struct rtnl_link *) obj); break; case RTM_NEWROUTE: - lcp_nl_route_add ((struct rtnl_route *) obj); - break; + { + nl_msg_info_t *msg_info = (nl_msg_info_t *) arg; + struct nlmsghdr *nlh = nlmsg_hdr (msg_info->msg); + lcp_nl_route_add ((struct rtnl_route *) obj, + (nlh->nlmsg_flags & NLM_F_REPLACE)); + break; + } case RTM_DELROUTE: lcp_nl_route_del ((struct rtnl_route *) obj); break; diff --git a/lcpng_netlink.h b/lcpng_netlink.h index b473523..c0efc2d 100644 --- a/lcpng_netlink.h +++ b/lcpng_netlink.h @@ -118,7 +118,7 @@ void lcp_nl_addr_add (struct rtnl_addr *ra); void lcp_nl_addr_del (struct rtnl_addr *ra); void lcp_nl_link_add (struct rtnl_link *rl, void *ctx); void lcp_nl_link_del (struct rtnl_link *rl); -void lcp_nl_route_add (struct rtnl_route *rr); +void lcp_nl_route_add (struct rtnl_route *rr, int is_replace); void lcp_nl_route_del (struct rtnl_route *rr); /* diff --git a/lcpng_nl_sync.c b/lcpng_nl_sync.c index 2a906e3..6aea17f 100644 --- a/lcpng_nl_sync.c +++ b/lcpng_nl_sync.c @@ -451,7 +451,7 @@ lcp_nl_route_del (struct rtnl_route *rr) } void -lcp_nl_route_add (struct rtnl_route *rr) +lcp_nl_route_add (struct rtnl_route *rr, int is_replace) { fib_entry_flag_t entry_flags; uint32_t table_id; @@ -459,7 +459,8 @@ lcp_nl_route_add (struct rtnl_route *rr) lcp_nl_table_t *nlt; uint8_t rtype, rproto; - LCP_NL_DBG ("route_add: netlink %U", format_nl_object, rr); + LCP_NL_DBG ("route_add: netlink %U %s", format_nl_object, rr, + is_replace?"replace":""); rtype = rtnl_route_get_type (rr); table_id = rtnl_route_get_table (rr); @@ -534,12 +535,12 @@ lcp_nl_route_add (struct rtnl_route *rr) rtnl_route_get_table (rr), format_fib_prefix, &pfx, format_fib_entry_flags, entry_flags); - if (pfx.fp_proto == FIB_PROTOCOL_IP6) - fib_table_entry_path_add2 (nlt->nlt_fib_index, &pfx, fib_src, - entry_flags, np.paths); - else + if (is_replace) fib_table_entry_update (nlt->nlt_fib_index, &pfx, fib_src, entry_flags, np.paths); + else + fib_table_entry_path_add2 (nlt->nlt_fib_index, &pfx, fib_src, + entry_flags, np.paths); } } else