Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108695548
D40426.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D40426.diff
View Options
diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c
--- a/sbin/ifconfig/carp.c
+++ b/sbin/ifconfig/carp.c
@@ -60,7 +60,7 @@
static const char *carp_states[] = { CARP_STATES };
-static void setcarp_callback(int, void *);
+static void setcarp_callback(if_ctx *, void *);
static int carpr_vhid = -1;
static int carpr_advskew = -1;
@@ -114,7 +114,7 @@
}
static void
-setcarp_callback(int s __unused, void *arg __unused)
+setcarp_callback(if_ctx *ctx __unused, void *arg __unused)
{
struct ifconfig_carp carpr = { };
diff --git a/sbin/ifconfig/ifclone.c b/sbin/ifconfig/ifclone.c
--- a/sbin/ifconfig/ifclone.c
+++ b/sbin/ifconfig/ifclone.c
@@ -118,13 +118,12 @@
* no parameters.
*/
static void
-ifclonecreate(int s, void *arg __unused)
+ifclonecreate(if_ctx *ctx, void *arg __unused)
{
- struct ifreq ifr;
+ struct ifreq ifr = {};
struct clone_defcb *dcp;
- memset(&ifr, 0, sizeof(ifr));
- (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
/* Try to find a default callback by filter */
SLIST_FOREACH(dcp, &clone_defcbh, next) {
@@ -145,9 +144,9 @@
if (dcp == NULL || dcp->clone_cb == NULL) {
/* NB: no parameters */
- ioctl_ifcreate(s, &ifr);
+ ifcreate_ioctl(ctx, &ifr);
} else {
- dcp->clone_cb(s, &ifr);
+ dcp->clone_cb(ctx, &ifr);
}
/*
@@ -161,7 +160,7 @@
}
static void
-clone_create(if_ctx *ctx __unused, const char *cmd __unused, int d __unused)
+clone_create(if_ctx *ctx, const char *cmd __unused, int d __unused)
{
callback_register(ifclonecreate, NULL);
}
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -53,13 +53,19 @@
struct afswtch;
struct cmd;
-struct ifconfig_context;
+struct snl_state;
+struct ifconfig_args;
+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 */
+};
+typedef const struct ifconfig_context if_ctx;
-typedef void c_func(const struct ifconfig_context *ctx, const char *cmd, int arg);
-typedef void c_func2(const struct ifconfig_context *ctx, const char *arg1,
- const char *arg2);
-typedef void c_func3(const struct ifconfig_context *ctx, const char *cmd,
- const char *arg);
+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);
+typedef void c_func3(if_ctx *ctx, const char *cmd, const char *arg);
struct cmd {
const char *c_name;
@@ -79,7 +85,7 @@
};
void cmd_register(struct cmd *);
-typedef void callback_func(int s, void *);
+typedef void callback_func(if_ctx *, void *);
void callback_register(callback_func *, void *);
/*
@@ -144,16 +150,6 @@
.c_next = NULL, \
}
-struct snl_state;
-struct ifconfig_args;
-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 */
-};
-typedef const struct ifconfig_context if_ctx;
-
#define ioctl_ctx(ctx, _req, ...) ioctl((ctx)->io_s, _req, ## __VA_ARGS__)
struct ifaddrs;
@@ -271,7 +267,7 @@
void ifmaybeload(struct ifconfig_args *args, const char *name);
typedef int clone_match_func(const char *);
-typedef void clone_callback_func(int, struct ifreq *);
+typedef void clone_callback_func(if_ctx *, struct ifreq *);
void clone_setdefcallback_prefix(const char *, clone_callback_func *);
void clone_setdefcallback_filter(clone_match_func *, clone_callback_func *);
@@ -303,7 +299,7 @@
void print_vhid(const struct ifaddrs *, const char *);
-void ioctl_ifcreate(int s, struct ifreq *);
+void ifcreate_ioctl(if_ctx *ctx, struct ifreq *ifr);
/* Helpers */
struct sockaddr_in;
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -201,9 +201,9 @@
}
void
-ioctl_ifcreate(int s, struct ifreq *ifr)
+ifcreate_ioctl(if_ctx *ctx, struct ifreq *ifr)
{
- if (ioctl(s, SIOCIFCREATE2, ifr) < 0) {
+ if (ioctl(ctx->io_s, SIOCIFCREATE2, ifr) < 0) {
switch (errno) {
case EEXIST:
errx(1, "interface %s already exists", ifr->ifr_name);
@@ -1143,7 +1143,7 @@
if (cb == NULL)
errx(1, "internal error, no callback");
callbacks = cb->cb_next;
- cb->cb_func(s, cb->cb_arg);
+ cb->cb_func(ctx, cb->cb_arg);
iscreate = 0;
/*
* Handle any address family spec that
@@ -1204,7 +1204,7 @@
* command-line arguments.
*/
for (cb = callbacks; cb != NULL; cb = cb->cb_next)
- cb->cb_func(s, cb->cb_arg);
+ cb->cb_func(ctx, cb->cb_arg);
/*
* Do deferred operations.
*/
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -447,10 +447,10 @@
}
static void
-setroam_cb(int s, void *arg)
+setroam_cb(if_ctx *ctx, void *arg)
{
struct ieee80211_roamparams_req *roam = arg;
- set80211(s, IEEE80211_IOC_ROAM, 0, sizeof(*roam), roam);
+ set80211(ctx->io_s, IEEE80211_IOC_ROAM, 0, sizeof(*roam), roam);
}
static void
@@ -465,10 +465,10 @@
}
static void
-settxparams_cb(int s, void *arg)
+settxparams_cb(if_ctx *ctx, void *arg)
{
struct ieee80211_txparams_req *txp = arg;
- set80211(s, IEEE80211_IOC_TXPARAMS, 0, sizeof(*txp), txp);
+ set80211(ctx->io_s, IEEE80211_IOC_TXPARAMS, 0, sizeof(*txp), txp);
}
static void
@@ -491,7 +491,7 @@
}
static void
-setregdomain_cb(int s, void *arg)
+setregdomain_cb(if_ctx *ctx, void *arg)
{
struct ieee80211_regdomain_req *req;
struct ieee80211_regdomain *rd = arg;
@@ -545,7 +545,7 @@
if (dc == NULL)
errx(1, "no space for device capabilities");
dc->dc_chaninfo.ic_nchans = MAXCHAN;
- getdevcaps(s, dc);
+ getdevcaps(ctx->io_s, dc);
#if 0
if (verbose) {
printf("drivercaps: 0x%x\n", dc->dc_drivercaps);
@@ -576,11 +576,11 @@
errx(1, "no space for channel list");
memcpy(chaninfo, &req->chaninfo,
IEEE80211_CHANINFO_SPACE(&req->chaninfo));
- print_channels(s, &req->chaninfo, 1/*allchans*/, 1/*verbose*/);
+ print_channels(ctx->io_s, &req->chaninfo, 1/*allchans*/, 1/*verbose*/);
}
if (req->chaninfo.ic_nchans == 0)
errx(1, "no channels calculated");
- set80211(s, IEEE80211_IOC_REGDOMAIN, 0,
+ set80211(ctx->io_s, IEEE80211_IOC_REGDOMAIN, 0,
IEEE80211_REGDOMAIN_SPACE(req), req);
free(req);
free(dc);
@@ -5739,7 +5739,7 @@
}
static void
-setdefregdomain(int s)
+setdefregdomain(if_ctx *ctx)
{
struct regdata *rdp = getregdata();
const struct regdomain *rd;
@@ -5750,7 +5750,7 @@
regdomain.country != CTRY_DEFAULT)
return;
- getregdomain(s);
+ getregdomain(ctx->io_s);
/* Check if it was already set by the driver. */
if (regdomain.regdomain != 0 ||
@@ -5767,7 +5767,7 @@
defaultcountry(rd);
/* Send changes to net80211. */
- setregdomain_cb(s, ®domain);
+ setregdomain_cb(ctx, ®domain);
/* Cleanup (so it can be overridden by subsequent parameters). */
regdomain.regdomain = 0;
@@ -5784,7 +5784,7 @@
};
static void
-wlan_create(int s, struct ifreq *ifr)
+wlan_create(if_ctx *ctx, struct ifreq *ifr)
{
static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
char orig_name[IFNAMSIZ];
@@ -5796,13 +5796,13 @@
memcmp(params.icp_bssid, zerobssid, sizeof(zerobssid)) == 0)
errx(1, "no bssid specified for WDS (use wlanbssid)");
ifr->ifr_data = (caddr_t) ¶ms;
- ioctl_ifcreate(s, ifr);
+ 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(s);
+ setdefregdomain(ctx);
strlcpy(name, orig_name, sizeof(name));
}
diff --git a/sbin/ifconfig/iflagg.c b/sbin/ifconfig/iflagg.c
--- a/sbin/ifconfig/iflagg.c
+++ b/sbin/ifconfig/iflagg.c
@@ -308,10 +308,10 @@
}
static void
-lagg_create(int s, struct ifreq *ifr)
+lagg_create(if_ctx *ctx, struct ifreq *ifr)
{
ifr->ifr_data = (caddr_t) ¶ms;
- ioctl_ifcreate(s, ifr);
+ ifcreate_ioctl(ctx, ifr);
}
static struct cmd lagg_cmds[] = {
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -90,7 +90,7 @@
#include "ifconfig.h"
-static void domediaopt(const char *, bool);
+static void domediaopt(if_ctx *, const char *, bool);
static ifmedia_t get_media_subtype(ifmedia_t, const char *);
static ifmedia_t get_media_mode(ifmedia_t, const char *);
static ifmedia_t get_media_options(ifmedia_t, const char *);
@@ -175,14 +175,14 @@
}
static void
-setifmediacallback(int s, void *arg)
+setifmediacallback(if_ctx *ctx, void *arg)
{
struct ifmediareq *ifmr = (struct ifmediareq *)arg;
static bool did_it = false;
if (!did_it) {
ifr.ifr_media = ifmr->ifm_current;
- if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0)
+ if (ioctl_ctx(ctx, SIOCSIFMEDIA, (caddr_t)&ifr) < 0)
err(1, "SIOCSIFMEDIA (media)");
free(ifmr);
did_it = true;
@@ -190,7 +190,7 @@
}
static void
-setmedia(if_ctx *ctx __unused, const char *val, int d __unused)
+setmedia(if_ctx *ctx, const char *val, int d __unused)
{
struct ifmediareq *ifmr;
int subtype;
@@ -217,21 +217,21 @@
}
static void
-setmediaopt(if_ctx *ctx __unused, const char *val, int d __unused)
+setmediaopt(if_ctx *ctx, const char *val, int d __unused)
{
- domediaopt(val, false);
+ domediaopt(ctx, val, false);
}
static void
-unsetmediaopt(if_ctx *ctx __unused, const char *val, int d __unused)
+unsetmediaopt(if_ctx *ctx, const char *val, int d __unused)
{
- domediaopt(val, true);
+ domediaopt(ctx, val, true);
}
static void
-domediaopt(const char *val, bool clear)
+domediaopt(if_ctx *ctx, const char *val, bool clear)
{
struct ifmediareq *ifmr;
ifmedia_t options;
@@ -256,7 +256,7 @@
}
static void
-setmediainst(if_ctx *ctx __unused, const char *val, int d __unused)
+setmediainst(if_ctx *ctx, const char *val, int d __unused)
{
struct ifmediareq *ifmr;
int inst;
@@ -275,7 +275,7 @@
}
static void
-setmediamode(if_ctx *ctx __unused, const char *val, int d __unused)
+setmediamode(if_ctx *ctx, const char *val, int d __unused)
{
struct ifmediareq *ifmr;
int mode;
diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
--- a/sbin/ifconfig/ifvlan.c
+++ b/sbin/ifconfig/ifvlan.c
@@ -158,7 +158,7 @@
}
static void
-vlan_create(int s, struct ifreq *ifr)
+vlan_create(if_ctx *ctx, struct ifreq *ifr)
{
vlan_parse_ethervid(ifr->ifr_name);
@@ -172,11 +172,11 @@
errx(1, "must specify a parent device for vlan create");
ifr->ifr_data = (caddr_t) ¶ms;
}
- ioctl_ifcreate(s, ifr);
+ ifcreate_ioctl(ctx, ifr);
}
static void
-vlan_cb(int s __unused, void *arg __unused)
+vlan_cb(if_ctx *ctx __unused, void *arg __unused)
{
if ((params.vlr_tag != NOTAG) ^ (params.vlr_parent[0] != '\0'))
errx(1, "both vlan and vlandev must be specified");
diff --git a/sbin/ifconfig/ifvxlan.c b/sbin/ifconfig/ifvxlan.c
--- a/sbin/ifconfig/ifvxlan.c
+++ b/sbin/ifconfig/ifvxlan.c
@@ -179,19 +179,13 @@
#undef _REMOTE_ADDR46
static void
-vxlan_cb(int s __unused, void *arg __unused)
-{
-
-}
-
-static void
-vxlan_create(int s, struct ifreq *ifr)
+vxlan_create(if_ctx *ctx, struct ifreq *ifr)
{
vxlan_check_params();
ifr->ifr_data = (caddr_t) ¶ms;
- ioctl_ifcreate(s, ifr);
+ ifcreate_ioctl(ctx, ifr);
}
static void
@@ -640,6 +634,5 @@
for (i = 0; i < nitems(vxlan_cmds); i++)
cmd_register(&vxlan_cmds[i]);
af_register(&af_vxlan);
- callback_register(vxlan_cb, NULL);
clone_setdefcallback_prefix("vxlan", vxlan_create);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 28, 9:11 AM (5 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16216822
Default Alt Text
D40426.diff (11 KB)
Attached To
Mode
D40426: ifconfig: add if_ctx argument to the generic and ifclone callbacks.
Attached
Detach File
Event Timeline
Log In to Comment