* [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified.
@ 2012-11-27 12:19 Jan Synacek
2012-11-27 12:19 ` [PATCH 2/2] arping: Call usage() before limiting capabilities Jan Synacek
2012-11-28 18:38 ` [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified YOSHIFUJI Hideaki
0 siblings, 2 replies; 4+ messages in thread
From: Jan Synacek @ 2012-11-27 12:19 UTC (permalink / raw)
To: yoshfuji; +Cc: netdev, Jan Synacek
By default, no interface string should be supplied. This ensures that we can
recognize if an interface was specified or omitted. Previously, when -I was not
used, default interface string was compiled-in and the automatic selection
didn't work correctly.
RH-Bugzilla: #879807
Signed-off-by: Jan Synacek <jsynacek@redhat.com>
---
Makefile | 4 +---
arping.c | 11 ++---------
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index ae92f34..b5bf84f 100644
--- a/Makefile
+++ b/Makefile
@@ -24,8 +24,6 @@ USE_SYSFS=no
USE_IDN=no
# Do not use getifaddrs
WITHOUT_IFADDRS=no
-# arping default device
-ARPING_DEFAULT_DEVICE=eth0
# rdisc server (-r option) support
ENABLE_RDISC_SERVER=no
# ping6 source routing (deprecated by RFC5095)
@@ -99,7 +97,7 @@ $(TARGETS): %: %.o
# -------------------------------------
# arping
-DEF_arping = $(DEF_SYSFS) $(DEF_CAP) $(DEF_IDN) $(DEF_WITHOUT_IFADDRS) -DDEFAULT_DEVICE=\"$(ARPING_DEFAULT_DEVICE)\"
+DEF_arping = $(DEF_SYSFS) $(DEF_CAP) $(DEF_IDN) $(DEF_WITHOUT_IFADDRS)
LIB_arping = $(LIB_SYSFS) $(LIB_CAP) $(LIB_IDN)
# clockdiff
diff --git a/arping.c b/arping.c
index f6433c2..ccb68a0 100644
--- a/arping.c
+++ b/arping.c
@@ -55,13 +55,6 @@ struct sysf_devattr_values;
static void usage(void) __attribute__((noreturn));
-#ifdef DEFAULT_DEVICE
-# define DEFAULT_DEVICE_STR DEFAULT_DEVICE
-#else
-# define DEFAULT_DEVICE_STR "no default"
-# define DEFAULT_DEVICE NULL
-#endif
-
struct device {
char *name;
int ifindex;
@@ -75,7 +68,7 @@ struct device {
int quit_on_reply=0;
struct device device = {
- .name = DEFAULT_DEVICE,
+ .name = NULL,
};
char *source;
struct in_addr src, dst;
@@ -128,7 +121,7 @@ void usage(void)
" -V : print version and exit\n"
" -c count : how many packets to send\n"
" -w timeout : how long to wait for a reply\n"
- " -I device : which ethernet device to use (" DEFAULT_DEVICE_STR ")\n"
+ " -I device : which ethernet device to use\n"
" -s source : source ip address\n"
" destination : ask for what ip address\n"
);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] arping: Call usage() before limiting capabilities.
2012-11-27 12:19 [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified Jan Synacek
@ 2012-11-27 12:19 ` Jan Synacek
2012-11-28 18:18 ` YOSHIFUJI Hideaki
2012-11-28 18:38 ` [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified YOSHIFUJI Hideaki
1 sibling, 1 reply; 4+ messages in thread
From: Jan Synacek @ 2012-11-27 12:19 UTC (permalink / raw)
To: yoshfuji; +Cc: netdev, Jan Synacek
Otherwise, running arping binary without the capabilities set results in printing
warnings with the usage.
Signed-off-by: Jan Synacek <jsynacek@redhat.com>
---
arping.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/arping.c b/arping.c
index ccb68a0..02e3d9c 100644
--- a/arping.c
+++ b/arping.c
@@ -959,19 +959,6 @@ main(int argc, char **argv)
int socket_errno;
int ch;
- limit_capabilities();
-
-#ifdef USE_IDN
- setlocale(LC_ALL, "");
-#endif
-
- enable_capability_raw();
-
- s = socket(PF_PACKET, SOCK_DGRAM, 0);
- socket_errno = errno;
-
- disable_capability_raw();
-
while ((ch = getopt(argc, argv, "h?bfDUAqc:w:s:I:V")) != EOF) {
switch(ch) {
case 'b':
@@ -1023,6 +1010,19 @@ main(int argc, char **argv)
target = *argv;
+ limit_capabilities();
+
+#ifdef USE_IDN
+ setlocale(LC_ALL, "");
+#endif
+
+ enable_capability_raw();
+
+ s = socket(PF_PACKET, SOCK_DGRAM, 0);
+ socket_errno = errno;
+
+ disable_capability_raw();
+
if (device.name && !*device.name)
device.name = NULL;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] arping: Call usage() before limiting capabilities.
2012-11-27 12:19 ` [PATCH 2/2] arping: Call usage() before limiting capabilities Jan Synacek
@ 2012-11-28 18:18 ` YOSHIFUJI Hideaki
0 siblings, 0 replies; 4+ messages in thread
From: YOSHIFUJI Hideaki @ 2012-11-28 18:18 UTC (permalink / raw)
To: Jan Synacek; +Cc: netdev, YOSHIFUJI Hideaki
Jan Synacek wrote:
> Otherwise, running arping binary without the capabilities set results in printing
> warnings with the usage.
>
> Signed-off-by: Jan Synacek <jsynacek@redhat.com>
Fixed in different way. ping/ping6 has also been fixed.
Thank you.
--yoshfuji
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified.
2012-11-27 12:19 [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified Jan Synacek
2012-11-27 12:19 ` [PATCH 2/2] arping: Call usage() before limiting capabilities Jan Synacek
@ 2012-11-28 18:38 ` YOSHIFUJI Hideaki
1 sibling, 0 replies; 4+ messages in thread
From: YOSHIFUJI Hideaki @ 2012-11-28 18:38 UTC (permalink / raw)
To: Jan Synacek; +Cc: netdev, YOSHIFUJI Hideaki
Jan Synacek wrote:
> By default, no interface string should be supplied. This ensures that we can
> recognize if an interface was specified or omitted. Previously, when -I was not
> used, default interface string was compiled-in and the automatic selection
> didn't work correctly.
Okay, but to retain default device support compiled in,
different patch applied.
Thank you, anyway.
P.S. Even if default interface compiled in, you can say "-I ''" to
override that.
--yoshfuji
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-28 18:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 12:19 [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified Jan Synacek
2012-11-27 12:19 ` [PATCH 2/2] arping: Call usage() before limiting capabilities Jan Synacek
2012-11-28 18:18 ` YOSHIFUJI Hideaki
2012-11-28 18:38 ` [PATCH 1/2] arping: Fix finding of a default interface when no -I is specified YOSHIFUJI Hideaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).