Page MenuHomeFreeBSD

D5341.id13476.diff
No OneTemporary

D5341.id13476.diff

Index: ifclone.c
===================================================================
--- ifclone.c
+++ ifclone.c
@@ -144,11 +144,12 @@
}
/*
- * If we get a different name back than we put in, print it.
+ * If we get a different name back than we put in, update record and
+ * indicate it should be printed later.
*/
if (strncmp(name, ifr.ifr_name, sizeof(name)) != 0) {
strlcpy(name, ifr.ifr_name, sizeof(name));
- printf("%s\n", name);
+ printifname = 1;
}
}
Index: ifconfig.h
===================================================================
--- ifconfig.h
+++ ifconfig.h
@@ -133,6 +133,7 @@
extern int printkeys;
extern int newaddr;
extern int verbose;
+extern int printifname;
void setifcap(const char *, int value, int s, const struct afswtch *);
Index: ifconfig.c
===================================================================
--- ifconfig.c
+++ ifconfig.c
@@ -93,6 +93,7 @@
int newaddr = 1;
int verbose;
int noload;
+int printifname = 0;
int supmedia = 0;
int printkeys = 0; /* Print keying material for interfaces. */
@@ -108,6 +109,8 @@
static struct afswtch *af_getbyfamily(int af);
static void af_other_status(int);
+void printifnamemaybe(void);
+
static struct option *opts = NULL;
struct ifa_order_elt {
@@ -297,6 +300,12 @@
return (result);
}
+void printifnamemaybe()
+{
+ if (printifname)
+ printf("%s\n", name);
+}
+
int
main(int argc, char *argv[])
{
@@ -314,6 +323,12 @@
size_t iflen;
all = downonly = uponly = namesonly = noload = verbose = 0;
+
+ /*
+ * Ensure we print interface name when expected to,
+ * even if we terminate early due to error.
+ */
+ atexit(printifnamemaybe);
/* Parse leading line options */
strlcpy(options, "adklmnuv", sizeof(options));
@@ -1010,6 +1025,7 @@
setifname(const char *val, int dummy __unused, int s,
const struct afswtch *afp)
{
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
char *newname;
newname = strdup(val);
@@ -1020,6 +1036,7 @@
free(newname);
err(1, "ioctl SIOCSIFNAME (set name)");
}
+ printifname = 1;
strlcpy(name, newname, sizeof(name));
free(newname);
}
@@ -1029,6 +1046,7 @@
setifdescr(const char *val, int dummy __unused, int s,
const struct afswtch *afp)
{
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
char *newdescr;
ifr.ifr_buffer.length = strlen(val) + 1;

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 5, 2:17 AM (3 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29266753
Default Alt Text
D5341.id13476.diff (2 KB)

Event Timeline