Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142245554
D40431.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D40431.diff
View Options
diff --git a/sbin/ifconfig/ifclone.c b/sbin/ifconfig/ifclone.c
--- a/sbin/ifconfig/ifclone.c
+++ b/sbin/ifconfig/ifclone.c
@@ -148,15 +148,6 @@
} else {
dcp->clone_cb(ctx, &ifr);
}
-
- /*
- * 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));
- printifname = 1;
- }
}
static void
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -58,10 +58,12 @@
struct ifconfig_context {
struct ifconfig_args *args;
const struct afswtch *afp;
- int io_s; /* fd to use for ioctl() */
- struct snl_state *io_ss; /* NETLINK_ROUTE socket */
+ int io_s; /* fd to use for ioctl() */
+ struct snl_state *io_ss; /* NETLINK_ROUTE socket */
+ char *ifname; /* Current interface name */
+ char _ifname_storage_ioctl[IFNAMSIZ];
};
-typedef const struct ifconfig_context if_ctx;
+typedef struct ifconfig_context if_ctx;
typedef void c_func(if_ctx *ctx, const char *cmd, int arg);
typedef void c_func2(if_ctx *ctx, const char *arg1, const char *arg2);
@@ -251,7 +253,6 @@
extern char name[IFNAMSIZ]; /* name of interface */
extern int allmedia;
extern int newaddr;
-extern int printifname;
extern int exit_code;
extern struct ifconfig_args global_args;
extern char *f_inet, *f_inet6, *f_ether, *f_addr;
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -102,12 +102,13 @@
static int doalias;
static int clearaddr;
int newaddr = 1;
-int printifname = 0;
struct ifconfig_args global_args;
int exit_code = 0;
+static char ifname_to_print[IFNAMSIZ]; /* Helper for printifnamemaybe() */
+
/* Formatter Strings */
char *f_inet, *f_inet6, *f_ether, *f_addr;
@@ -198,9 +199,22 @@
exit(1);
}
+static void
+ifname_update(if_ctx *ctx, const char *name)
+{
+ strlcpy(ctx->_ifname_storage_ioctl, name, sizeof(ctx->_ifname_storage_ioctl));
+ ctx->ifname = ctx->_ifname_storage_ioctl;
+
+ strlcpy(ifname_to_print, name, sizeof(ifname_to_print));
+}
+
void
ifcreate_ioctl(if_ctx *ctx, struct ifreq *ifr)
{
+ char ifname_orig[IFNAMSIZ];
+
+ strlcpy(ifname_orig, ifr->ifr_name, sizeof(ifname_orig));
+
if (ioctl(ctx->io_s, SIOCIFCREATE2, ifr) < 0) {
switch (errno) {
case EEXIST:
@@ -209,6 +223,9 @@
err(1, "SIOCIFCREATE2 (%s)", ifr->ifr_name);
}
}
+
+ if (strncmp(ifname_orig, ifr->ifr_name, sizeof(ifname_orig)) != 0)
+ ifname_update(ctx, ifr->ifr_name);
}
#ifdef WITHOUT_NETLINK
@@ -402,8 +419,8 @@
static void
printifnamemaybe(void)
{
- if (printifname)
- printf("%s\n", name);
+ if (ifname_to_print[0] != '\0')
+ printf("%s\n", ifname_to_print);
}
static void
@@ -1520,8 +1537,7 @@
free(newname);
err(1, "ioctl SIOCSIFNAME (set name)");
}
- printifname = 1;
- strlcpy(name, newname, sizeof(name));
+ ifname_update(ctx, newname);
free(newname);
}
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -5800,7 +5800,6 @@
wlan_create(if_ctx *ctx, struct ifreq *ifr)
{
static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
- char orig_name[IFNAMSIZ];
if (params.icp_parent[0] == '\0')
errx(1, "must specify a parent device (wlandev) when creating "
@@ -5811,13 +5810,7 @@
ifr->ifr_data = (caddr_t) ¶ms;
ifcreate_ioctl(ctx, ifr);
- /* XXX preserve original name for ifclonecreate(). */
- strlcpy(orig_name, name, sizeof(orig_name));
- strlcpy(name, ifr->ifr_name, sizeof(name));
-
setdefregdomain(ctx);
-
- strlcpy(name, orig_name, sizeof(name));
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 18, 6:24 PM (14 h, 29 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27714751
Default Alt Text
D40431.diff (3 KB)
Attached To
Mode
D40431: ifconfig: renove global printifname variable.
Attached
Detach File
Event Timeline
Log In to Comment