static int usnic_is_nlreply_err(struct nlmsghdr *nlm_hdr) { if (nlm_hdr->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *e = (struct nlmsgerr *)nlmsg_data(nlm_hdr); if (nlm_hdr->nlmsg_len >= (__u32)NLMSG_SIZE(sizeof(*e))) usnic_strerror(e->error, "Received a netlink error message"); else usnic_err( "Received a truncated netlink error message\n"); return 1; } return 0; }
static int usnic_is_nlreply_err(struct nlmsghdr *nlm_hdr, struct usnic_rt_cb_arg *arg) { if (nlm_hdr->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *e = (struct nlmsgerr *)nlmsg_data(nlm_hdr); if (nlm_hdr->nlmsg_len >= (__u32)NLMSG_SIZE(sizeof(*e))) { usnic_strerror(e->error, "Received a netlink error message"); /* Sometimes nl_send() succeeds, but the * request fails because the kernel is * temporarily out of resources. In these * cases, we should tell the caller that they * should try again. */ if (e->error == -ECONNREFUSED) { arg->retry = 1; } } else usnic_err( "Received a truncated netlink error message\n"); return 1; } return 0; }