From e0cc58f9b7421d1b63bc64c90f25f742fbae5777 Mon Sep 17 00:00:00 2001 From: Pravin B Shelar Date: Thu, 16 Oct 2014 11:38:16 -0700 Subject: [PATCH] route-table: extract gw information. Routing table will be used by ovs userspace tunneling, it need to know gw address, following commit extract gw information from netlink message so that ovs can populate it in ovs route table. Signed-off-by: Pravin B Shelar Acked-by: Thomas Graf --- lib/route-table.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/route-table.c b/lib/route-table.c index cb8f0f758..b16831559 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -41,6 +41,7 @@ struct route_data { /* Extracted from Netlink attributes. */ ovs_be32 rta_dst; /* 0 if missing. */ + ovs_be32 rta_gw; char ifname[IFNAMSIZ]; /* Interface name. */ }; @@ -205,6 +206,7 @@ route_table_parse(struct ofpbuf *buf, struct route_table_msg *change) static const struct nl_policy policy[] = { [RTA_DST] = { .type = NL_A_U32, .optional = true }, [RTA_OIF] = { .type = NL_A_U32, .optional = false }, + [RTA_GATEWAY] = { .type = NL_A_U32, .optional = true }, }; struct nlattr *attrs[ARRAY_SIZE(policy)]; @@ -251,6 +253,10 @@ route_table_parse(struct ofpbuf *buf, struct route_table_msg *change) if (attrs[RTA_DST]) { change->rd.rta_dst = nl_attr_get_be32(attrs[RTA_DST]); } + if (attrs[RTA_GATEWAY]) { + change->rd.rta_gw = nl_attr_get_be32(attrs[RTA_GATEWAY]); + } + } else { VLOG_DBG_RL(&rl, "received unparseable rtnetlink route message"); @@ -272,7 +278,8 @@ route_table_handle_msg(const struct route_table_msg *change) if (change->relevant && change->nlmsg_type == RTM_NEWROUTE) { const struct route_data *rd = &change->rd; - ovs_router_insert(rd->rta_dst, rd->rtm_dst_len, rd->ifname, 0); + ovs_router_insert(rd->rta_dst, rd->rtm_dst_len, + rd->ifname, rd->rta_gw); } } -- 2.20.1