From: stephen@networkplumber.org (Stephen Hemminger)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] xdp: Sample xdp program implementing ip forward
Date: Tue, 10 Oct 2017 10:19:21 -0700 [thread overview]
Message-ID: <20171010101921.30136d48@shemminger-XPS-13-9360> (raw)
In-Reply-To: <1507620532-25804-2-git-send-email-Christina.Jacob@cavium.com>
On Tue, 10 Oct 2017 12:58:52 +0530
Christina Jacob <christina.jacob.koikara@gmail.com> wrote:
> +/* Get the mac address of the interface given interface name */
> +static long *getmac(char *iface)
> +{
> + int fd;
> + struct ifreq ifr;
> + long *mac = NULL;
> +
> + fd = socket(AF_INET, SOCK_DGRAM, 0);
> + ifr.ifr_addr.sa_family = AF_INET;
> + strncpy(ifr.ifr_name, iface, IFNAMSIZ - 1);
> + ioctl(fd, SIOCGIFHWADDR, &ifr);
> + mac = (long *)ifr.ifr_hwaddr.sa_data;
> + close(fd);
> + return mac;
Always check return value of ioctl.
You are assuming sizeof(long) > 6 bytes.
Also the byte order.
next prev parent reply other threads:[~2017-10-10 17:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 7:28 [PATCH v2] XDP Program for Ip forward Christina Jacob
2017-10-10 7:28 ` [PATCH v2] xdp: Sample xdp program implementing ip forward Christina Jacob
2017-10-10 17:19 ` Stephen Hemminger [this message]
2017-10-10 21:37 ` David Daney
2017-10-28 13:37 ` Christina Jacob
2017-10-10 17:21 ` Stephen Hemminger
2017-10-10 19:06 ` Jesper Dangaard Brouer
2017-10-11 10:08 ` David Laight
2017-10-10 13:12 ` [PATCH v2] XDP Program for Ip forward Jesper Dangaard Brouer
2017-10-10 14:00 ` Jesper Dangaard Brouer
2017-10-11 17:06 ` Christina Jacob
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=20171010101921.30136d48@shemminger-XPS-13-9360 \
--to=stephen@networkplumber.org \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox