Message ID | 1468044967-9236-2-git-send-email-denkenz@gmail.com (mailing list archive) |
---|---|
State | RFC |
Delegated to: | Johannes Berg |
Headers | show |
Hi Denis, > This function emits NL80211_CMD_NEW_INTERFACE or > NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core > to notify userspace applications such as wpa_supplicant when a netdev > related to a wireless device has been added or removed. > > Signed-off-by: Denis Kenzior <denkenz@gmail.com> > --- > net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ > net/wireless/nl80211.h | 3 +++ > 2 files changed, 31 insertions(+) > > diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c > index f39fd4d..da03e17 100644 > --- a/net/wireless/nl80211.c > +++ b/net/wireless/nl80211.c > @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, > NL80211_MCGRP_CONFIG, GFP_KERNEL); > } > > +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, > + struct wireless_dev *wdev, > + enum nl80211_commands cmd) > +{ > + struct sk_buff *msg; > + bool removal; > + > + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && > + cmd != NL80211_CMD_DEL_INTERFACE); I would assume that BUILD_BUG_ON does a way job better here. Regards Marcel -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 9-7-2016 16:05, Marcel Holtmann wrote: > Hi Denis, > >> This function emits NL80211_CMD_NEW_INTERFACE or >> NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core >> to notify userspace applications such as wpa_supplicant when a netdev >> related to a wireless device has been added or removed. >> >> Signed-off-by: Denis Kenzior <denkenz@gmail.com> >> --- >> net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ >> net/wireless/nl80211.h | 3 +++ >> 2 files changed, 31 insertions(+) >> >> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c >> index f39fd4d..da03e17 100644 >> --- a/net/wireless/nl80211.c >> +++ b/net/wireless/nl80211.c >> @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, >> NL80211_MCGRP_CONFIG, GFP_KERNEL); >> } >> >> +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, >> + struct wireless_dev *wdev, >> + enum nl80211_commands cmd) >> +{ >> + struct sk_buff *msg; >> + bool removal; >> + >> + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && >> + cmd != NL80211_CMD_DEL_INTERFACE); > > I would assume that BUILD_BUG_ON does a way job better here. Why? I don't see why the condition would be compile-time constant as it can be called from outside nl80211.c. Regards, Arend > Regards > > Marcel > > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Arend, >>> This function emits NL80211_CMD_NEW_INTERFACE or >>> NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core >>> to notify userspace applications such as wpa_supplicant when a netdev >>> related to a wireless device has been added or removed. >>> >>> Signed-off-by: Denis Kenzior <denkenz@gmail.com> >>> --- >>> net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ >>> net/wireless/nl80211.h | 3 +++ >>> 2 files changed, 31 insertions(+) >>> >>> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c >>> index f39fd4d..da03e17 100644 >>> --- a/net/wireless/nl80211.c >>> +++ b/net/wireless/nl80211.c >>> @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, >>> NL80211_MCGRP_CONFIG, GFP_KERNEL); >>> } >>> >>> +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, >>> + struct wireless_dev *wdev, >>> + enum nl80211_commands cmd) >>> +{ >>> + struct sk_buff *msg; >>> + bool removal; >>> + >>> + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && >>> + cmd != NL80211_CMD_DEL_INTERFACE); >> >> I would assume that BUILD_BUG_ON does a way job better here. > > Why? I don't see why the condition would be compile-time constant as it > can be called from outside nl80211.c. what has that to do with it. No matter who calls it, the point is to ensure that it is called for new/del interface. And if a caller uses it for something else, then it should fail and it should fail loudly. Regards Marcel -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Marcel, On Mon, Jul 11, 2016 at 5:47 AM, Marcel Holtmann <marcel@holtmann.org> wrote: > Hi Arend, > >>>> This function emits NL80211_CMD_NEW_INTERFACE or >>>> NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core >>>> to notify userspace applications such as wpa_supplicant when a netdev >>>> related to a wireless device has been added or removed. >>>> >>>> Signed-off-by: Denis Kenzior <denkenz@gmail.com> >>>> --- >>>> net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ >>>> net/wireless/nl80211.h | 3 +++ >>>> 2 files changed, 31 insertions(+) >>>> >>>> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c >>>> index f39fd4d..da03e17 100644 >>>> --- a/net/wireless/nl80211.c >>>> +++ b/net/wireless/nl80211.c >>>> @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, >>>> NL80211_MCGRP_CONFIG, GFP_KERNEL); >>>> } >>>> >>>> +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, >>>> + struct wireless_dev *wdev, >>>> + enum nl80211_commands cmd) >>>> +{ >>>> + struct sk_buff *msg; >>>> + bool removal; >>>> + >>>> + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && >>>> + cmd != NL80211_CMD_DEL_INTERFACE); >>> >>> I would assume that BUILD_BUG_ON does a way job better here. >> >> Why? I don't see why the condition would be compile-time constant as it >> can be called from outside nl80211.c. > > what has that to do with it. No matter who calls it, the point is to ensure that it is called for new/del interface. And if a caller uses it for something else, then it should fail and it should fail loudly. Let me ask this question another way: How is BUILD_BUG_ON going to warn about a runtime error? Thanks,
Hi Julian, >>>>> This function emits NL80211_CMD_NEW_INTERFACE or >>>>> NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core >>>>> to notify userspace applications such as wpa_supplicant when a netdev >>>>> related to a wireless device has been added or removed. >>>>> >>>>> Signed-off-by: Denis Kenzior <denkenz@gmail.com> >>>>> --- >>>>> net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ >>>>> net/wireless/nl80211.h | 3 +++ >>>>> 2 files changed, 31 insertions(+) >>>>> >>>>> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c >>>>> index f39fd4d..da03e17 100644 >>>>> --- a/net/wireless/nl80211.c >>>>> +++ b/net/wireless/nl80211.c >>>>> @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, >>>>> NL80211_MCGRP_CONFIG, GFP_KERNEL); >>>>> } >>>>> >>>>> +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, >>>>> + struct wireless_dev *wdev, >>>>> + enum nl80211_commands cmd) >>>>> +{ >>>>> + struct sk_buff *msg; >>>>> + bool removal; >>>>> + >>>>> + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && >>>>> + cmd != NL80211_CMD_DEL_INTERFACE); >>>> >>>> I would assume that BUILD_BUG_ON does a way job better here. >>> >>> Why? I don't see why the condition would be compile-time constant as it >>> can be called from outside nl80211.c. >> >> what has that to do with it. No matter who calls it, the point is to ensure that it is called for new/del interface. And if a caller uses it for something else, then it should fail and it should fail loudly. > > Let me ask this question another way: > > How is BUILD_BUG_ON going to warn about a runtime error? how is this a runtime error in the first place? If you call it with any other nl80211_commands than the two explicitly allowed, you are doing something wrong. If BUILD_BUG_ON has limitations, then fine, but please don't tell me this is a runtime error. Regards Marcel -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 11-7-2016 9:39, Marcel Holtmann wrote: > Hi Julian, > >>>>>> This function emits NL80211_CMD_NEW_INTERFACE or >>>>>> NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core >>>>>> to notify userspace applications such as wpa_supplicant when a netdev >>>>>> related to a wireless device has been added or removed. >>>>>> >>>>>> Signed-off-by: Denis Kenzior <denkenz@gmail.com> >>>>>> --- >>>>>> net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ >>>>>> net/wireless/nl80211.h | 3 +++ >>>>>> 2 files changed, 31 insertions(+) >>>>>> >>>>>> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c >>>>>> index f39fd4d..da03e17 100644 >>>>>> --- a/net/wireless/nl80211.c >>>>>> +++ b/net/wireless/nl80211.c >>>>>> @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, >>>>>> NL80211_MCGRP_CONFIG, GFP_KERNEL); >>>>>> } >>>>>> >>>>>> +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, >>>>>> + struct wireless_dev *wdev, >>>>>> + enum nl80211_commands cmd) >>>>>> +{ >>>>>> + struct sk_buff *msg; >>>>>> + bool removal; >>>>>> + >>>>>> + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && >>>>>> + cmd != NL80211_CMD_DEL_INTERFACE); >>>>> >>>>> I would assume that BUILD_BUG_ON does a way job better here. >>>> >>>> Why? I don't see why the condition would be compile-time constant as it >>>> can be called from outside nl80211.c. >>> >>> what has that to do with it. No matter who calls it, the point is to ensure that it is called for new/del interface. And if a caller uses it for something else, then it should fail and it should fail loudly. >> >> Let me ask this question another way: >> >> How is BUILD_BUG_ON going to warn about a runtime error? > > how is this a runtime error in the first place? If you call it with any other nl80211_commands than the two explicitly allowed, you are doing something wrong. If BUILD_BUG_ON has limitations, then fine, but please don't tell me this is a runtime error. Hi Marcel, Indeed it is not a run-time error. The limitation of BUILD_BUG_ON is that the condition has to be compile-time constant. This means upon compiling nl80211.c. BUILD_BUG_ON does not work at link-time so upon linking nl80211.o with core.o where the function is called from (in patches 2 and 3). Regards, Arend -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index f39fd4d..da03e17 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -11855,6 +11855,34 @@ void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, NL80211_MCGRP_CONFIG, GFP_KERNEL); } +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, + struct wireless_dev *wdev, + enum nl80211_commands cmd) +{ + struct sk_buff *msg; + bool removal; + + WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE && + cmd != NL80211_CMD_DEL_INTERFACE); + + if (cmd == NL80211_CMD_DEL_INTERFACE) + removal = true; + else + removal = false; + + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return; + + if (nl80211_send_iface(msg, 0, 0, 0, rdev, wdev, removal) < 0) { + nlmsg_free(msg); + return; + } + + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, + NL80211_MCGRP_CONFIG, GFP_KERNEL); +} + static int nl80211_add_scan_req(struct sk_buff *msg, struct cfg80211_registered_device *rdev) { diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h index a63f402..6f6b73c 100644 --- a/net/wireless/nl80211.h +++ b/net/wireless/nl80211.h @@ -7,6 +7,9 @@ int nl80211_init(void); void nl80211_exit(void); void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev, enum nl80211_commands cmd); +void nl80211_notify_iface(struct cfg80211_registered_device *rdev, + struct wireless_dev *wdev, + enum nl80211_commands cmd); void nl80211_send_scan_start(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev); struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
This function emits NL80211_CMD_NEW_INTERFACE or NL80211_CMD_DEL_INTERFACE events. This is meant to be used by the core to notify userspace applications such as wpa_supplicant when a netdev related to a wireless device has been added or removed. Signed-off-by: Denis Kenzior <denkenz@gmail.com> --- net/wireless/nl80211.c | 28 ++++++++++++++++++++++++++++ net/wireless/nl80211.h | 3 +++ 2 files changed, 31 insertions(+)