Date: Thu, 9 Jul 2009 23:12:48 +0000 (UTC) From: Sam Leffler <sam@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r195520 - projects/mesh11s/sys/net80211 Message-ID: <200907092312.n69NCmAF000104@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sam Date: Thu Jul 9 23:12:47 2009 New Revision: 195520 URL: http://svn.freebsd.org/changeset/base/195520 Log: Give mac acl's some tlc: o use the linker set mechanism for ioctls and remove the aclator hooks; this pushes more code out of ieee80211_ioctl.c and allows further simplifications in the future o mark ieee80211req_maclist __packed to fix list mac on arm Modified: projects/mesh11s/sys/net80211/ieee80211_acl.c projects/mesh11s/sys/net80211/ieee80211_ioctl.c projects/mesh11s/sys/net80211/ieee80211_ioctl.h projects/mesh11s/sys/net80211/ieee80211_proto.h Modified: projects/mesh11s/sys/net80211/ieee80211_acl.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_acl.c Thu Jul 9 22:21:18 2009 (r195519) +++ projects/mesh11s/sys/net80211/ieee80211_acl.c Thu Jul 9 23:12:47 2009 (r195520) @@ -277,20 +277,18 @@ acl_getpolicy(struct ieee80211vap *vap) } static int -acl_setioctl(struct ieee80211vap *vap, struct ieee80211req *ireq) +acl_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) { - - return EINVAL; -} - -static int -acl_getioctl(struct ieee80211vap *vap, struct ieee80211req *ireq) -{ - struct aclstate *as = vap->iv_as; + struct aclstate *as; struct acl *acl; struct ieee80211req_maclist *ap; int error, space, i; + if (ireq->i_type != IEEE80211_IOC_MACCMD) + return ENOSYS; + if (vap->iv_acl == NULL) + return EINVAL; + as = vap->iv_as; switch (ireq->i_val) { case IEEE80211_MACCMD_POLICY: ireq->i_val = as->as_policy; @@ -322,6 +320,85 @@ acl_getioctl(struct ieee80211vap *vap, s } return EINVAL; } +IEEE80211_IOCTL_GET(acl, acl_ioctl_get80211); + +static int +acl_ioctl_macmac(struct ieee80211vap *vap, struct ieee80211req *ireq) +{ + uint8_t mac[IEEE80211_ADDR_LEN]; + const struct ieee80211_aclator *acl = vap->iv_acl; + int error; + + if (ireq->i_len != sizeof(mac)) + return EINVAL; + error = copyin(ireq->i_data, mac, ireq->i_len); + if (error) + return error; + if (acl == NULL) { + acl = ieee80211_aclator_get("mac"); + if (acl == NULL || !acl_attach(vap)) + return EINVAL; + vap->iv_acl = acl; + } + if (ireq->i_type == IEEE80211_IOC_ADDMAC) + acl_add(vap, mac); + else + acl_remove(vap, mac); + return 0; +} + +static int +acl_ioctl_setmaccmd(struct ieee80211vap *vap, struct ieee80211req *ireq) +{ + const struct ieee80211_aclator *acl = vap->iv_acl; + + switch (ireq->i_val) { + case IEEE80211_MACCMD_POLICY_OPEN: + case IEEE80211_MACCMD_POLICY_ALLOW: + case IEEE80211_MACCMD_POLICY_DENY: + case IEEE80211_MACCMD_POLICY_RADIUS: + if (acl == NULL) { + acl = ieee80211_aclator_get("mac"); + if (acl == NULL || !acl_attach(vap)) + return EINVAL; + vap->iv_acl = acl; + } + acl_setpolicy(vap, ireq->i_val); + break; + case IEEE80211_MACCMD_FLUSH: + if (acl != NULL) + acl_free_all(vap); + /* NB: silently ignore when not in use */ + break; + case IEEE80211_MACCMD_DETACH: + if (acl != NULL) { + vap->iv_acl = NULL; + acl_detach(vap); + } + break; + default: + return EINVAL; + } + return 0; +} + +static int +acl_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) +{ + switch (ireq->i_type) { + case IEEE80211_IOC_ADDMAC: + case IEEE80211_IOC_DELMAC: + return acl_ioctl_macmac(vap, ireq); + break; + case IEEE80211_IOC_MACCMD: + return acl_ioctl_setmaccmd(vap, ireq); + break; + default: + return ENOSYS; + } + return 0; +} +IEEE80211_IOCTL_SET(acl, acl_ioctl_set80211); static const struct ieee80211_aclator mac = { .iac_name = "mac", @@ -333,7 +410,5 @@ static const struct ieee80211_aclator ma .iac_flush = acl_free_all, .iac_setpolicy = acl_setpolicy, .iac_getpolicy = acl_getpolicy, - .iac_setioctl = acl_setioctl, - .iac_getioctl = acl_getioctl, }; IEEE80211_ACL_MODULE(wlan_acl, mac, 1); Modified: projects/mesh11s/sys/net80211/ieee80211_ioctl.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_ioctl.c Thu Jul 9 22:21:18 2009 (r195519) +++ projects/mesh11s/sys/net80211/ieee80211_ioctl.c Thu Jul 9 23:12:47 2009 (r195520) @@ -585,14 +585,6 @@ ieee80211_ioctl_getwmeparam(struct ieee8 } static __noinline int -ieee80211_ioctl_getmaccmd(struct ieee80211vap *vap, struct ieee80211req *ireq) -{ - const struct ieee80211_aclator *acl = vap->iv_acl; - - return (acl == NULL ? EINVAL : acl->iac_getioctl(vap, ireq)); -} - -static __noinline int ieee80211_ioctl_getcurchan(struct ieee80211vap *vap, struct ieee80211req *ireq) { struct ieee80211com *ic = vap->iv_ic; @@ -985,9 +977,6 @@ ieee80211_ioctl_get80211(struct ieee8021 case IEEE80211_IOC_FRAGTHRESHOLD: ireq->i_val = vap->iv_fragthreshold; break; - case IEEE80211_IOC_MACCMD: - error = ieee80211_ioctl_getmaccmd(vap, ireq); - break; case IEEE80211_IOC_BURST: ireq->i_val = (vap->iv_flags & IEEE80211_F_BURST) != 0; break; @@ -1514,69 +1503,6 @@ ieee80211_ioctl_setmlme(struct ieee80211 } static __noinline int -ieee80211_ioctl_macmac(struct ieee80211vap *vap, struct ieee80211req *ireq) -{ - uint8_t mac[IEEE80211_ADDR_LEN]; - const struct ieee80211_aclator *acl = vap->iv_acl; - int error; - - if (ireq->i_len != sizeof(mac)) - return EINVAL; - error = copyin(ireq->i_data, mac, ireq->i_len); - if (error) - return error; - if (acl == NULL) { - acl = ieee80211_aclator_get("mac"); - if (acl == NULL || !acl->iac_attach(vap)) - return EINVAL; - vap->iv_acl = acl; - } - if (ireq->i_type == IEEE80211_IOC_ADDMAC) - acl->iac_add(vap, mac); - else - acl->iac_remove(vap, mac); - return 0; -} - -static __noinline int -ieee80211_ioctl_setmaccmd(struct ieee80211vap *vap, struct ieee80211req *ireq) -{ - const struct ieee80211_aclator *acl = vap->iv_acl; - - switch (ireq->i_val) { - case IEEE80211_MACCMD_POLICY_OPEN: - case IEEE80211_MACCMD_POLICY_ALLOW: - case IEEE80211_MACCMD_POLICY_DENY: - case IEEE80211_MACCMD_POLICY_RADIUS: - if (acl == NULL) { - acl = ieee80211_aclator_get("mac"); - if (acl == NULL || !acl->iac_attach(vap)) - return EINVAL; - vap->iv_acl = acl; - } - acl->iac_setpolicy(vap, ireq->i_val); - break; - case IEEE80211_MACCMD_FLUSH: - if (acl != NULL) - acl->iac_flush(vap); - /* NB: silently ignore when not in use */ - break; - case IEEE80211_MACCMD_DETACH: - if (acl != NULL) { - vap->iv_acl = NULL; - acl->iac_detach(vap); - } - break; - default: - if (acl == NULL) - return EINVAL; - else - return acl->iac_setioctl(vap, ireq); - } - return 0; -} - -static __noinline int ieee80211_ioctl_setchanlist(struct ieee80211vap *vap, struct ieee80211req *ireq) { struct ieee80211com *ic = vap->iv_ic; @@ -2833,13 +2759,6 @@ ieee80211_ioctl_set80211(struct ieee8021 ieee80211_syncflag_ht(vap, -IEEE80211_FHT_USEHT40); error = ENETRESET; break; - case IEEE80211_IOC_ADDMAC: - case IEEE80211_IOC_DELMAC: - error = ieee80211_ioctl_macmac(vap, ireq); - break; - case IEEE80211_IOC_MACCMD: - error = ieee80211_ioctl_setmaccmd(vap, ireq); - break; case IEEE80211_IOC_STA_STATS: error = ieee80211_ioctl_setstastats(vap, ireq); break; Modified: projects/mesh11s/sys/net80211/ieee80211_ioctl.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_ioctl.h Thu Jul 9 22:21:18 2009 (r195519) +++ projects/mesh11s/sys/net80211/ieee80211_ioctl.h Thu Jul 9 23:12:47 2009 (r195520) @@ -315,7 +315,7 @@ enum { struct ieee80211req_maclist { uint8_t ml_macaddr[IEEE80211_ADDR_LEN]; -}; +} __packed; /* * Mesh Routing Table Operations. Modified: projects/mesh11s/sys/net80211/ieee80211_proto.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_proto.h Thu Jul 9 22:21:18 2009 (r195519) +++ projects/mesh11s/sys/net80211/ieee80211_proto.h Thu Jul 9 23:12:47 2009 (r195520) @@ -177,7 +177,6 @@ void ieee80211_authenticator_register(in void ieee80211_authenticator_unregister(int type); const struct ieee80211_authenticator *ieee80211_authenticator_get(int auth); -struct ieee80211req; /* * Template for an MAC ACL policy module. Such modules * register with the protocol code and are passed the sender's @@ -196,8 +195,6 @@ struct ieee80211_aclator { int (*iac_flush)(struct ieee80211vap *); int (*iac_setpolicy)(struct ieee80211vap *, int); int (*iac_getpolicy)(struct ieee80211vap *); - int (*iac_setioctl)(struct ieee80211vap *, struct ieee80211req *); - int (*iac_getioctl)(struct ieee80211vap *, struct ieee80211req *); }; void ieee80211_aclator_register(const struct ieee80211_aclator *); void ieee80211_aclator_unregister(const struct ieee80211_aclator *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907092312.n69NCmAF000104>