1
0

120-cfg80211_allow_perm_addr_change.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --- a/net/wireless/sysfs.c
  2. +++ b/net/wireless/sysfs.c
  3. @@ -24,18 +24,35 @@ static inline struct cfg80211_registered
  4. return container_of(dev, struct cfg80211_registered_device, wiphy.dev);
  5. }
  6. -#define SHOW_FMT(name, fmt, member) \
  7. +#define SHOW_FMT(name, fmt, member, mode) \
  8. static ssize_t name ## _show(struct device *dev, \
  9. struct device_attribute *attr, \
  10. char *buf) \
  11. { \
  12. return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \
  13. } \
  14. -static DEVICE_ATTR_RO(name)
  15. +static DEVICE_ATTR_##mode(name)
  16. -SHOW_FMT(index, "%d", wiphy_idx);
  17. -SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
  18. -SHOW_FMT(address_mask, "%pM", wiphy.addr_mask);
  19. +static ssize_t macaddress_store(struct device *dev,
  20. + struct device_attribute *attr,
  21. + const char *buf, size_t len)
  22. +{
  23. + u8 mac[ETH_ALEN];
  24. +
  25. + if (!mac_pton(buf, mac))
  26. + return -EINVAL;
  27. +
  28. + if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n')
  29. + return -EINVAL;
  30. +
  31. + memcpy(dev_to_rdev(dev)->wiphy.perm_addr, mac, ETH_ALEN);
  32. +
  33. + return strnlen(buf, len);
  34. +}
  35. +
  36. +SHOW_FMT(index, "%d", wiphy_idx, RO);
  37. +SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW);
  38. +SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO);
  39. static ssize_t name_show(struct device *dev,
  40. struct device_attribute *attr,