From: Marek Lindner <mareklindner@neomailbox.ch>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH next 2/3] batctl: implement vlan-to-link helper functions
Date: Mon, 06 Jan 2014 03:07:16 +0800 [thread overview]
Message-ID: <2109637.jlPLNyN0nR@diderot> (raw)
In-Reply-To: <1388912394-824-2-git-send-email-antonio@meshcoding.com>
[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]
On Sunday 05 January 2014 09:59:53 Antonio Quartulli wrote:
> +/**
> + * vlan_get_link_dump - receive and dump a get_link rtnl reply
> + * @sock: the socket to listen for the reply on
> + * @buf: pointer to the buffer where the reply has to be dumped to
> + * @buflen: length of the buffer
> + *
> + * Returns the amount of dumped bytes
> + */
> +static ssize_t vlan_get_link_dump(int sock, void *buf, size_t buflen)
> +{
> + struct iovec iov;
> + struct msghdr msg;
> + struct sockaddr_nl nladdr;
> + ssize_t ret = -1;
> +
> + memset(&msg, 0, sizeof(msg));
> + memset(&iov, 0, sizeof(iov));
> +
> + msg.msg_iov = &iov;
> + msg.msg_iovlen = 1;
> + msg.msg_controllen = 0;
> + msg.msg_control = NULL;
> + msg.msg_flags = 0;
> + msg.msg_name = &nladdr;
> + msg.msg_namelen = sizeof(nladdr);
> +
> + iov.iov_len = buflen;
> + iov.iov_base = buf;
> +
> + ret = recvmsg(sock, &msg, 0);
> + if (ret < 0)
> + goto err;
> +
> + return ret;
> +err:
> + free(buf);
> + return ret;
> +}
Do we double free 'buf' in case of an error ?
> +/**
> + * vlan_get_link_open - send a get_link request
> + * @ifname: the interface to query
> + *
> + * Returns 0 in case of success or a negative error code otherwise
> + */
> +static int vlan_get_link_open(const char *ifname)
> +{
> + struct {
> + struct nlmsghdr hdr;
> + struct ifinfomsg ifi;
> + /* attribute has to be NLMAG aligned */
NLMSG aligned ?
Cheers,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2014-01-05 19:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-05 8:59 [B.A.T.M.A.N.] [PATCH next 1/3] batctl: introduce rtnl_open() helper function Antonio Quartulli
2014-01-05 8:59 ` [B.A.T.M.A.N.] [PATCH next 2/3] batctl: implement vlan-to-link helper functions Antonio Quartulli
2014-01-05 19:07 ` Marek Lindner [this message]
2014-01-05 19:33 ` Antonio Quartulli
2014-01-05 8:59 ` [B.A.T.M.A.N.] [PATCH next 3/3] batctl: add sys framework for VLAN support Antonio Quartulli
2014-01-05 14:04 ` [B.A.T.M.A.N.] [PATCH next 1/3] batctl: introduce rtnl_open() helper function Marek Lindner
2014-01-05 19:45 ` Antonio Quartulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2109637.jlPLNyN0nR@diderot \
--to=mareklindner@neomailbox.ch \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.