From: ebiederm@xmission•com (Eric W. Biederman)
To: Stephen Hemminger <shemming@brocade•com>
Cc: <netdev@vger•kernel.org>
Subject: [PATCH net-next 3/8] iproute2: Add support for printing AF_PACKET addresses
Date: Fri, 13 Mar 2015 13:54:31 -0500 [thread overview]
Message-ID: <87r3ssramw.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <87bnjwspek.fsf@x220.int.ebiederm.org> (Eric W. Biederman's message of "Fri, 13 Mar 2015 13:50:11 -0500")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission•com>
---
lib/utils.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/lib/utils.c b/lib/utils.c
index a97eae9d5148..65d1632ddbc1 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -25,11 +25,12 @@
#include <asm/types.h>
#include <linux/pkt_sched.h>
#include <linux/param.h>
+#include <linux/if_arp.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
-
+#include "rt_names.h"
#include "utils.h"
#include "namespace.h"
@@ -397,6 +398,18 @@ int get_addr_1(inet_prefix *addr, const char *name, int family)
return 0;
}
+ if (family == AF_PACKET) {
+ int len;
+ len = ll_addr_a2n((char *)&addr->data, sizeof(addr->data), name);
+ if (len < 0)
+ return -1;
+
+ addr->family = AF_PACKET;
+ addr->bytelen = len;
+ addr->bitlen = len * 8;
+ return 0;
+ }
+
if (strchr(name, ':')) {
addr->family = AF_INET6;
if (family != AF_UNSPEC && family != AF_INET6)
@@ -485,10 +498,6 @@ done:
int get_addr(inet_prefix *dst, const char *arg, int family)
{
- if (family == AF_PACKET) {
- fprintf(stderr, "Error: \"%s\" may be inet address, but it is not allowed in this context.\n", arg);
- exit(1);
- }
if (get_addr_1(dst, arg, family)) {
fprintf(stderr, "Error: an inet address is expected rather than \"%s\".\n", arg);
exit(1);
@@ -638,6 +647,8 @@ const char *rt_addr_n2a(int af, int len, const void *addr, char *buf, int buflen
memcpy(dna.a_addr, addr, 2);
return dnet_ntop(af, &dna, buf, buflen);
}
+ case AF_PACKET:
+ return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen);
default:
return "???";
}
--
2.2.1
next prev parent reply other threads:[~2015-03-13 18:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 18:50 [PATCH net-next] iproute2: MPLS support Eric W. Biederman
2015-03-13 18:52 ` [PATCH net-next 1/8] iproute2: Add a source addres length parameter to rt_addr_n2a Eric W. Biederman
2015-03-13 18:52 ` [PATCH net-next 2/8] iproute2: Make the addr argument of ll_addr_n2a const Eric W. Biederman
2015-03-13 18:54 ` Eric W. Biederman [this message]
2015-03-13 18:55 ` [PATCH net-next 4/8] iproute2: Add address family to/from string helper functions Eric W. Biederman
2015-03-13 18:56 ` [PATCH net-next 5/8] iproute2: misc whitespace cleanup Eric W. Biederman
2015-03-13 18:57 ` [PATCH net-next 6/8] iproute2: Add support for RTA_VIA attributes Eric W. Biederman
2015-03-13 18:58 ` [PATCH net-next 7/8] iproute2: Add support for the RTA_NEWDST attribute Eric W. Biederman
2015-03-13 18:59 ` [PATCH net-next 8/8] iproute2: Add basic mpls support to iproute Eric W. Biederman
[not found] ` <c3ad7d77783046d38e5b23b5e1fe0f71@BRMWP-EXMB11.corp.brocade.com>
2015-03-15 19:33 ` [PATCH net-next 1/8] iproute2: Add a source addres length parameter to rt_addr_n2a Stephen Hemminger
2015-03-15 19:42 ` Eric W. Biederman
2015-03-15 19:47 ` [PATCH net-next 0/8] iproute2: MPLS support (now with af_bit_len) Eric W. Biederman
2015-03-15 19:48 ` [PATCH net-next 1/8] iproute2: Add a source addres length parameter to rt_addr_n2a Eric W. Biederman
2015-03-15 19:49 ` [PATCH net-next 2/8] iproute2: Make the addr argument of ll_addr_n2a const Eric W. Biederman
2015-03-15 19:49 ` [PATCH net-next 3/8] iproute2: Add support for printing AF_PACKET addresses Eric W. Biederman
2015-03-15 19:50 ` [PATCH net-next 4/8] iproute2: Add address family to/from string helper functions Eric W. Biederman
2015-03-15 19:51 ` [PATCH net-next 5/8] iproute2: misc whitespace cleanup Eric W. Biederman
2015-03-15 19:52 ` [PATCH net-next 6/8] iproute2: Add support for the RTA_VIA attribute Eric W. Biederman
2015-04-06 23:04 ` roopa
2015-04-06 23:27 ` Andy Gospodarek
2015-04-07 14:55 ` roopa
2015-04-07 16:09 ` Eric W. Biederman
2015-04-07 16:58 ` Vivek Venkatraman
2015-04-07 19:38 ` Eric W. Biederman
2015-04-07 21:12 ` Vivek Venkatraman
2015-04-07 18:15 ` roopa
2015-03-15 19:53 ` [PATCH net-next 7/8] iproute2: Add support for the RTA_NEWDST attribute Eric W. Biederman
2015-03-15 19:53 ` [PATCH net-next 8/8] iproute2: Add basic mpls support to iproute Eric W. Biederman
2015-03-24 22:36 ` [PATCH net-next] iproute2: MPLS support Stephen Hemminger
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=87r3ssramw.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=shemming@brocade$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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