} \
} while (0)
+# define NETLINK_MSG_APPEND(msg, datalen, dataptr) \
+do { \
+ if (nlmsg_append(msg, dataptr, datalen, NLMSG_ALIGNTO) < 0) { \
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", \
+ _("allocated netlink buffer is too small")); \
+ return -1; \
+ } \
+} while (0)
+
/* State for a single netlink event handle */
struct virNetlinkEventHandle {
return -1;
}
- if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) < 0)
- goto buffer_too_small;
+ NETLINK_MSG_APPEND(nl_msg, sizeof(ifinfo), &ifinfo);
if (ifname)
NETLINK_MSG_PUT(nl_msg, IFLA_IFNAME, (strlen(ifname) + 1), ifname);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
return rc;
-
- buffer_too_small:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("allocated netlink buffer is too small"));
- return rc;
}
return -1;
}
- if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) < 0)
- goto buffer_too_small;
+ NETLINK_MSG_APPEND(nl_msg, sizeof(ifinfo), &ifinfo);
NETLINK_MSG_PUT(nl_msg, IFLA_IFNAME, (strlen(ifname) + 1), ifname);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
return -1;
-
- buffer_too_small:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("allocated netlink buffer is too small"));
- return -1;
}
return -1;
}
- if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) < 0)
- goto buffer_too_small;
+ NETLINK_MSG_APPEND(nl_msg, sizeof(ifinfo), &ifinfo);
NETLINK_MSG_PUT(nl_msg, IFLA_IFNAME, (strlen(ifname) + 1), ifname);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
return -1;
-
- buffer_too_small:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("allocated netlink buffer is too small"));
- return -1;
}
/**
return -1;
}
- if (nlmsg_append(nl_msg, &ndinfo, sizeof(ndinfo), NLMSG_ALIGNTO) < 0)
- goto buffer_too_small;
-
+ NETLINK_MSG_APPEND(nl_msg, sizeof(ndinfo), &ndinfo);
if (virNetlinkCommand(nl_msg, &resp, &recvbuflen,
src_pid, dst_pid, NETLINK_ROUTE, 0) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
return -1;
-
- buffer_too_small:
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("allocated netlink buffer is too small"));
- return -1;
}
int