X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fnetlink-socket.c;h=8cb1b8eef4d4d9570fd66716538b6bd27f36c702;hb=6d7d2ace1494936d11b8cabcec26c7e4d0fdda68;hp=9562d38e5a8f67576af825e66c0e8a52cff32a86;hpb=69fc54f47bbc35e81bfe2e38e57f5dcfd9858df4;p=sliver-openvswitch.git diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index 9562d38e5..8cb1b8eef 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,6 @@ VLOG_DEFINE_THIS_MODULE(netlink_socket); COVERAGE_DEFINE(netlink_overflow); COVERAGE_DEFINE(netlink_received); COVERAGE_DEFINE(netlink_recv_jumbo); -COVERAGE_DEFINE(netlink_send); COVERAGE_DEFINE(netlink_sent); /* Linux header file confusion causes this to be undefined. */ @@ -338,7 +337,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait) } if (msg.msg_flags & MSG_TRUNC) { - VLOG_ERR_RL(&rl, "truncated message (longer than %zu bytes)", + VLOG_ERR_RL(&rl, "truncated message (longer than %"PRIuSIZE" bytes)", sizeof tail); return E2BIG; } @@ -347,7 +346,7 @@ nl_sock_recv__(struct nl_sock *sock, struct ofpbuf *buf, bool wait) if (retval < sizeof *nlmsghdr || nlmsghdr->nlmsg_len < sizeof *nlmsghdr || nlmsghdr->nlmsg_len > retval) { - VLOG_ERR_RL(&rl, "received invalid nlmsg (%zd bytes < %zu)", + VLOG_ERR_RL(&rl, "received invalid nlmsg (%"PRIuSIZE"d bytes < %"PRIuSIZE")", retval, sizeof *nlmsghdr); return EPROTO; } @@ -676,16 +675,17 @@ nl_sock_drain(struct nl_sock *sock) * Netlink socket created with the given 'protocol', and initializes 'dump' to * reflect the state of the operation. * - * nlmsg_len in 'msg' will be finalized to match msg->size, and nlmsg_pid will - * be set to the Netlink socket's pid, before the message is sent. NLM_F_DUMP - * and NLM_F_ACK will be set in nlmsg_flags. + * 'request' must contain a Netlink message. Before sending the message, + * nlmsg_len will be finalized to match request->size, and nlmsg_pid will be + * set to the Netlink socket's pid. NLM_F_DUMP and NLM_F_ACK will be set in + * nlmsg_flags. * * The design of this Netlink socket library ensures that the dump is reliable. * - * This function provides no status indication. An error status for the entire - * dump operation is provided when it is completed by calling nl_dump_done(). + * This function provides no status indication. nl_dump_done() provides an + * error status for the entire dump operation. * - * The caller is responsible for destroying 'request'. + * The caller must eventually destroy 'request'. */ void nl_dump_start(struct nl_dump *dump, int protocol, const struct ofpbuf *request) @@ -699,7 +699,7 @@ nl_dump_start(struct nl_dump *dump, int protocol, const struct ofpbuf *request) nl_msg_nlmsghdr(request)->nlmsg_flags |= NLM_F_DUMP | NLM_F_ACK; dump->status = nl_sock_send__(dump->sock, request, nl_sock_allocate_seq(dump->sock, 1), true); - dump->seq = nl_msg_nlmsghdr(request)->nlmsg_seq; + dump->nl_seq = nl_msg_nlmsghdr(request)->nlmsg_seq; } /* Helper function for nl_dump_next(). */ @@ -715,9 +715,9 @@ nl_dump_recv(struct nl_dump *dump) } nlmsghdr = nl_msg_nlmsghdr(&dump->buffer); - if (dump->seq != nlmsghdr->nlmsg_seq) { + if (dump->nl_seq != nlmsghdr->nlmsg_seq) { VLOG_DBG_RL(&rl, "ignoring seq %#"PRIx32" != expected %#"PRIx32, - nlmsghdr->nlmsg_seq, dump->seq); + nlmsghdr->nlmsg_seq, dump->nl_seq); return EAGAIN; } @@ -925,12 +925,10 @@ do_lookup_genl_family(const char *name, struct nlattr **attrs, /* Finds the multicast group called 'group_name' in genl family 'family_name'. * When successful, writes its result to 'multicast_group' and returns 0. * Otherwise, clears 'multicast_group' and returns a positive error code. - * - * Some kernels do not support looking up a multicast group with this function. - * In this case, 'multicast_group' will be populated with 'fallback'. */ + */ int nl_lookup_genl_mcgroup(const char *family_name, const char *group_name, - unsigned int *multicast_group, unsigned int fallback) + unsigned int *multicast_group) { struct nlattr *family_attrs[ARRAY_SIZE(family_policy)]; const struct nlattr *mc; @@ -945,10 +943,7 @@ nl_lookup_genl_mcgroup(const char *family_name, const char *group_name, } if (!family_attrs[CTRL_ATTR_MCAST_GROUPS]) { - *multicast_group = fallback; - VLOG_WARN("%s-%s: has no multicast group, using fallback %d", - family_name, group_name, *multicast_group); - error = 0; + error = EPROTO; goto exit; }