Skip to content

Commit d2f227e

Browse files
committed
UCS/NETLINK: code review fixes
1 parent 41c9c1f commit d2f227e

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/ucs/sys/netlink.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ ucs_netlink_parse_rt_entry_cb(const struct nlmsghdr *nlh, void *arg)
233233

234234
memset(&new_rule->dest, 0, sizeof(new_rule->dest));
235235
new_rule->dest.ss_family = rt_msg->rtm_family;
236-
if (rt_msg->rtm_dst_len != 0) {
236+
if (dst_in_addr != NULL) {
237237
if (ucs_sockaddr_set_inet_addr((struct sockaddr *)&new_rule->dest,
238238
dst_in_addr) != UCS_OK) {
239239
ucs_array_pop_back(iface_rules);
@@ -250,7 +250,6 @@ static void ucs_netlink_lookup_route(ucs_netlink_route_info_t *info)
250250
{
251251
ucs_netlink_rt_rules_t *iface_rules;
252252
ucs_netlink_route_entry_t *curr_entry;
253-
int is_default_gw;
254253
khiter_t iter;
255254

256255
iter = kh_get(ucs_netlink_rt_cache, &ucs_netlink_routing_table_cache,
@@ -262,11 +261,10 @@ static void ucs_netlink_lookup_route(ucs_netlink_route_info_t *info)
262261

263262
iface_rules = &kh_val(&ucs_netlink_routing_table_cache, iter);
264263
ucs_array_for_each(curr_entry, iface_rules) {
265-
is_default_gw = (curr_entry->subnet_prefix_len == 0);
266264

267265
/* Skip default gateway routes if not allowed (e.g., for
268266
IPoIB remote devices) */
269-
if (is_default_gw && !info->allow_default_gw) {
267+
if ((curr_entry->subnet_prefix_len == 0) && !info->allow_default_gw) {
270268
ucs_trace("iface_index=%d: skipping default gateway route",
271269
info->if_index);
272270
continue;
@@ -312,8 +310,8 @@ int ucs_netlink_route_exists(int if_index, const struct sockaddr *sa_remote,
312310
return info.found;
313311
}
314312

315-
int ucs_netlink_ethernet_device_route_exists(int if_index,
316-
const struct sockaddr *sa_remote)
313+
int ucs_netlink_route_exists_allow_default(int if_index,
314+
const struct sockaddr *sa_remote)
317315
{
318316
return ucs_netlink_route_exists(if_index, sa_remote, 1);
319317
}

src/ucs/sys/netlink.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ int ucs_netlink_route_exists(int if_index, const struct sockaddr *sa_remote,
6262

6363
/**
6464
* Check whether a routing table rule exists for a given network
65-
* interface name and a destination address (allows default gateway).
65+
* interface name and a destination address, while allowing default gateway
66+
* routes.
6667
*
6768
* @param [in] if_index A global index representing the network interface,
6869
as assigned by the system (e.g., obtained via
@@ -71,8 +72,8 @@ int ucs_netlink_route_exists(int if_index, const struct sockaddr *sa_remote,
7172
*
7273
* @return 1 if rule exists, or 0 otherwise.
7374
*/
74-
int ucs_netlink_ethernet_device_route_exists(int if_index,
75-
const struct sockaddr *sa_remote);
75+
int ucs_netlink_route_exists_allow_default(int if_index,
76+
const struct sockaddr *sa_remote);
7677

7778
END_C_DECLS
7879

src/ucs/sys/sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ int ucs_netif_is_ipoib(const char *if_name)
190190
return 0;
191191
}
192192

193-
return (ifr.ifr_hwaddr.sa_family == ARPHRD_INFINIBAND);
193+
return ifr.ifr_hwaddr.sa_family == ARPHRD_INFINIBAND;
194194
}
195195

196196
static uint64_t ucs_get_mac_address()

src/uct/ib/base/ib_iface.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ uct_ib_iface_roce_is_routable(uct_ib_iface_t *iface, uint8_t gid_index,
710710
return 0;
711711
}
712712

713-
if (!ucs_netlink_ethernet_device_route_exists(ndev_index, sa_remote)) {
713+
if (!ucs_netlink_route_exists_allow_default(ndev_index, sa_remote)) {
714714
/* try to use loopback interface for reachability check, because it may
715715
* be used for routing in case of an interface with VRF is configured
716716
* and a RoCE IP interface uses this VRF table for routing.
@@ -721,8 +721,8 @@ uct_ib_iface_roce_is_routable(uct_ib_iface_t *iface, uint8_t gid_index,
721721
return 0;
722722
}
723723

724-
if (!ucs_netlink_ethernet_device_route_exists(lo_ndev_index,
725-
sa_remote)) {
724+
if (!ucs_netlink_route_exists_allow_default(lo_ndev_index,
725+
sa_remote)) {
726726
uct_iface_fill_info_str_buf(params,
727727
"remote address %s is not routable "
728728
"neither by interface "UCT_IB_IFACE_FMT

src/uct/tcp/tcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ typedef enum uct_tcp_device_addr_flags {
296296
* @ref uct_iface_local_addr_ns_t for loopback reachability
297297
*/
298298
UCT_TCP_DEVICE_ADDR_FLAG_LOOPBACK = UCS_BIT(0),
299+
299300
/**
300301
* Interface is IPoIB (IP over InfiniBand)
301302
*/

0 commit comments

Comments
 (0)