diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-12-11 20:07:58 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-12-11 20:07:58 +0000 |
commit | b000a45618c25f980cfa09540e7381b2ddd1d2ec (patch) | |
tree | fd7fe843a3537a15f00fdfdcfca768d667dd3b06 | |
parent | d8951a253e1574d3fe6a3700cf164bce615da38a (diff) | |
download | upstream-b000a45618c25f980cfa09540e7381b2ddd1d2ec.tar.gz upstream-b000a45618c25f980cfa09540e7381b2ddd1d2ec.tar.bz2 upstream-b000a45618c25f980cfa09540e7381b2ddd1d2ec.zip |
cfg80211: add support for changing the device mac address via sysfs
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43638 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch b/package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch new file mode 100644 index 0000000000..ffd8807ccc --- /dev/null +++ b/package/kernel/mac80211/patches/120-cfg80211_allow_perm_addr_change.patch @@ -0,0 +1,43 @@ +--- a/net/wireless/sysfs.c ++++ b/net/wireless/sysfs.c +@@ -24,18 +24,35 @@ static inline struct cfg80211_registered + return container_of(dev, struct cfg80211_registered_device, wiphy.dev); + } + +-#define SHOW_FMT(name, fmt, member) \ ++#define SHOW_FMT(name, fmt, member, mode) \ + static ssize_t name ## _show(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ + } \ +-static DEVICE_ATTR_RO(name) ++static DEVICE_ATTR_##mode(name) + +-SHOW_FMT(index, "%d", wiphy_idx); +-SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); +-SHOW_FMT(address_mask, "%pM", wiphy.addr_mask); ++static ssize_t macaddress_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, size_t len) ++{ ++ u8 mac[ETH_ALEN]; ++ ++ if (!mac_pton(buf, mac)) ++ return -EINVAL; ++ ++ if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n') ++ return -EINVAL; ++ ++ memcpy(dev_to_rdev(dev)->wiphy.perm_addr, mac, ETH_ALEN); ++ ++ return strnlen(buf, len); ++} ++ ++SHOW_FMT(index, "%d", wiphy_idx, RO); ++SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW); ++SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO); + + static ssize_t name_show(struct device *dev, + struct device_attribute *attr, |