summaryrefslogtreecommitdiff
path: root/zebra/kernel_netlink.c
diff options
context:
space:
mode:
authorChirag Shah <chirag@nvidia.com>2022-05-30 20:51:17 -0700
committerChirag Shah <chirag@nvidia.com>2022-05-31 13:50:48 -0700
commite5b1de8a1190dc99460f7e209706251a51557f7a (patch)
tree22023199c821c5d9819fad321c96757782f9b9b5 /zebra/kernel_netlink.c
parentda49af8cdaac854536211d5fef6efbdc792d5cae (diff)
zebra: add error check condition to sock option
Adding error checking condition which was missed in PR-11216. *** CID 1517953: Error handling issues (CHECKED_RETURN) /zebra/kernel_netlink.c: 313 in netlink_socket() 307 memset(&snl, 0, sizeof(snl)); 308 snl.nl_family = AF_NETLINK; 309 snl.nl_groups = groups; 310 311 #if defined SOL_NETLINK 312 if (ext_groups) >>> CID 1517953: Error handling issues (CHECKED_RETURN) >>> Calling "setsockopt(sock, 270, 1, &ext_groups, 8U)" without checking return value. This library function may fail and return an error code. 313 setsockopt(sock, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, 314 &ext_groups, sizeof(ext_groups)); 315 #endif 316 317 /* Bind the socket to the netlink structure for anything. */ 318 ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl)); Signed-off-by: Chirag Shah <chirag@nvidia.com>
Diffstat (limited to 'zebra/kernel_netlink.c')
-rw-r--r--zebra/kernel_netlink.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 7adbb5ab85..7e47822a2c 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -309,9 +309,16 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
snl.nl_groups = groups;
#if defined SOL_NETLINK
- if (ext_groups)
- setsockopt(sock, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
- &ext_groups, sizeof(ext_groups));
+ if (ext_groups) {
+ ret = setsockopt(sock, SOL_NETLINK,
+ NETLINK_ADD_MEMBERSHIP, &ext_groups,
+ sizeof(ext_groups));
+ if (ret < 0) {
+ zlog_notice(
+ "can't setsockopt NETLINK_ADD_MEMBERSHIP: %s(%d)",
+ safe_strerror(errno), errno);
+ }
+ }
#endif
/* Bind the socket to the netlink structure for anything. */