ifconfig <if> join: show list of configured ess ids

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

ifconfig <if> join: show list of configured ess ids

Sebastian Benoit-3
Hi,

with this diff,

  ifconfig <if> join

will print the list of networks that are configured for autojoin.

$ ifconfig iwm0 join
iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
        lladdr a4:7f:da:a4:d7:c1
        index 1 priority 4 llprio 3
        groups: wlan egress
        media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
        status: active
        ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
        join:   gesamtkunstwerk
                fn0rd
                Gaeste
                WLAN


comments? oks?

(benno_join_list_5.diff)

diff --git sbin/ifconfig/ifconfig.c sbin/ifconfig/ifconfig.c
index 9bfb1751aab..de6aabf4fba 100644
--- sbin/ifconfig/ifconfig.c
+++ sbin/ifconfig/ifconfig.c
@@ -163,6 +163,7 @@ int newaddr = 0;
 int af = AF_INET;
 int explicit_prefix = 0;
 int Lflag = 1;
+int show_join = 0;
 
 int showmediaflag;
 int showcapsflag;
@@ -633,6 +634,7 @@ void in6_status(int);
 void in6_getaddr(const char *, int);
 void in6_getprefix(const char *, int);
 void ieee80211_status(void);
+void join_status(void);
 void ieee80211_listchans(void);
 void ieee80211_listnodes(void);
 void ieee80211_printnode(struct ieee80211_nodereq *);
@@ -1656,7 +1658,7 @@ setifjoin(const char *val, int d)
  int len;
 
  if (val == NULL) {
- /* TODO: display the list of join'd networks */
+ show_join = 1;
  return;
  }
 
@@ -2292,14 +2294,68 @@ ieee80211_status(void)
  putchar(' ');
  printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
  }
-
  putchar('\n');
+ if (show_join)
+ join_status();
  if (shownet80211chans)
  ieee80211_listchans();
  else if (shownet80211nodes)
  ieee80211_listnodes();
 }
 
+void
+join_status(void)
+{
+ struct ieee80211_joinreq_all ja;
+ struct ieee80211_join *jn = NULL;
+ int jsz = IEEE80211_CACHE_SIZE;
+ int ojsz;
+ int i;
+ int r;
+
+ bzero(&ja, sizeof(ja));
+ jn = recallocarray(NULL, 0, jsz, sizeof(*jn));
+ if (jn == NULL)
+ err(1, "recallocarray");
+ ojsz = jsz;
+ while (1) {
+ ja.ja_node = jn;
+ ja.ja_size = jsz * sizeof(*jn);
+ strlcpy(ja.ja_ifname, name, sizeof(ja.ja_ifname));
+
+ if ((r = ioctl(s, SIOCG80211JOINALL, &ja)) != 0) {
+ if (errno == E2BIG) {
+ jsz += IEEE80211_CACHE_SIZE;
+ if (jsz > 10*IEEE80211_CACHE_SIZE) {
+ warn("SIOCG80211JOINALL");
+ return;
+ }
+ jn = recallocarray(jn, ojsz, jsz, sizeof(*jn));
+ if (jn == NULL)
+ err(1, "recallocarray");
+ ojsz = jsz;
+ continue;
+ } else if (errno != ENOENT)
+ warn("SIOCG80211JOINALL");
+ return;
+ }
+ break;
+ }
+
+ if (!ja.ja_nodes)
+ return;
+
+ fputs("\tjoin:\t", stdout);
+ for (i = 0; i < ja.ja_nodes; i++) {
+ if (i > 0)
+ printf("\t\t");
+ if (jn[i].i_len > IEEE80211_NWID_LEN)
+ jn[i].i_len = IEEE80211_NWID_LEN;
+ print_string(jn[i].i_nwid, jn[i].i_len);
+ putchar('\n');
+ }
+}
+
 void
 ieee80211_listchans(void)
 {
diff --git sys/net80211/ieee80211.h sys/net80211/ieee80211.h
index d7be80a4562..b02cb7924d3 100644
--- sys/net80211/ieee80211.h
+++ sys/net80211/ieee80211.h
@@ -1023,4 +1023,6 @@ enum ieee80211_htprot {
  IEEE80211_HTPROT_NONHT_MIXED /* non-HT STA associated to our BSS */
 };
 
+#define IEEE80211_CACHE_SIZE 100
+
 #endif /* _NET80211_IEEE80211_H_ */
diff --git sys/net80211/ieee80211_ioctl.c sys/net80211/ieee80211_ioctl.c
index 4d6b7eb1b71..b41b4fe09d8 100644
--- sys/net80211/ieee80211_ioctl.c
+++ sys/net80211/ieee80211_ioctl.c
@@ -391,8 +391,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
  struct ieee80211com *ic = (void *)ifp;
  struct ifreq *ifr = (struct ifreq *)data;
  int i, error = 0;
+ size_t len;
  struct ieee80211_nwid nwid;
  struct ieee80211_join join;
+ struct ieee80211_joinreq_all *ja;
  struct ieee80211_ess *ess;
  struct ieee80211_wpapsk *psk;
  struct ieee80211_keyavail *ka;
@@ -488,6 +490,26 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
  }
  }
  break;
+ case SIOCG80211JOINALL:
+ ja = (struct ieee80211_joinreq_all *)data;
+ ja->ja_nodes = len = 0;
+ TAILQ_FOREACH(ess, &ic->ic_ess, ess_next) {
+ if (len + sizeof(struct ieee80211_nodereq) >=
+    ja->ja_size) {
+ error = E2BIG;
+ break;
+ }
+ memset(&join, 0, sizeof(struct ieee80211_join));
+ join.i_len = ess->esslen;
+ memcpy(&join.i_nwid, ess->essid, join.i_len);
+ error = copyout(&join, &ja->ja_node[ja->ja_nodes],
+    sizeof(struct ieee80211_nodereq));
+ if (error)
+ break;
+ len += sizeof(struct ieee80211_join);
+ ja->ja_nodes++;
+ }
+ break;
  case SIOCS80211NWKEY:
  if ((error = suser(curproc)) != 0)
  break;
diff --git sys/net80211/ieee80211_ioctl.h sys/net80211/ieee80211_ioctl.h
index 9ea74127b22..ea19d8a9550 100644
--- sys/net80211/ieee80211_ioctl.h
+++ sys/net80211/ieee80211_ioctl.h
@@ -275,6 +275,7 @@ struct ieee80211_keyrun {
 
 #define SIOCS80211SCAN _IOW('i', 210, struct ifreq)
 
+#define SIOCG80211JOINALL _IOWR('i', 218, struct ieee80211_joinreq_all)
 #define SIOCS80211JOIN _IOWR('i', 255, struct ifreq)
 #define SIOCG80211JOIN _IOWR('i', 256, struct ifreq)
 
@@ -288,6 +289,14 @@ struct ieee80211_join {
  struct ieee80211_nwkey i_nwkey;
 };
 
+struct ieee80211_joinreq_all {
+ char ja_ifname[IFNAMSIZ];
+ int ja_nodes; /* returned count */
+ size_t ja_size;  /* size of node buffer */
+ struct ieee80211_join *ja_node;  /* allocated node buffer */
+};
+
+
 #define IEEE80211_JOIN_SHOW 0x01
 #define IEEE80211_JOIN_FOUND 0x02
 #define IEEE80211_JOIN_DEL 0x04
diff --git sys/net80211/ieee80211_node.h sys/net80211/ieee80211_node.h
index 882df583190..afd9b4ce438 100644
--- sys/net80211/ieee80211_node.h
+++ sys/net80211/ieee80211_node.h
@@ -39,7 +39,7 @@
 #define IEEE80211_TRANS_WAIT 5 /* transition wait */
 #define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */
 #define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT)
-#define IEEE80211_CACHE_SIZE 100
+
 #define IEEE80211_CACHE_WAIT 30
 
 struct ieee80211_rateset {

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Jason McIntyre-2
On Sat, Aug 04, 2018 at 09:12:27PM +0200, Sebastian Benoit wrote:

> Hi,
>
> with this diff,
>
>   ifconfig <if> join
>
> will print the list of networks that are configured for autojoin.
>
> $ ifconfig iwm0 join
> iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
>         lladdr a4:7f:da:a4:d7:c1
>         index 1 priority 4 llprio 3
>         groups: wlan egress
>         media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
>         status: active
>         ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
>         join:   gesamtkunstwerk
>                 fn0rd
>                 Gaeste
>                 WLAN
>
>
> comments? oks?
>

this is what the man page says we already do (not that i've tested it).
i'm sure peter told me that's what running it without an argument does.

jmc

> (benno_join_list_5.diff)
>
> diff --git sbin/ifconfig/ifconfig.c sbin/ifconfig/ifconfig.c
> index 9bfb1751aab..de6aabf4fba 100644
> --- sbin/ifconfig/ifconfig.c
> +++ sbin/ifconfig/ifconfig.c
> @@ -163,6 +163,7 @@ int newaddr = 0;
>  int af = AF_INET;
>  int explicit_prefix = 0;
>  int Lflag = 1;
> +int show_join = 0;
>  
>  int showmediaflag;
>  int showcapsflag;
> @@ -633,6 +634,7 @@ void in6_status(int);
>  void in6_getaddr(const char *, int);
>  void in6_getprefix(const char *, int);
>  void ieee80211_status(void);
> +void join_status(void);
>  void ieee80211_listchans(void);
>  void ieee80211_listnodes(void);
>  void ieee80211_printnode(struct ieee80211_nodereq *);
> @@ -1656,7 +1658,7 @@ setifjoin(const char *val, int d)
>   int len;
>  
>   if (val == NULL) {
> - /* TODO: display the list of join'd networks */
> + show_join = 1;
>   return;
>   }
>  
> @@ -2292,14 +2294,68 @@ ieee80211_status(void)
>   putchar(' ');
>   printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
>   }
> -
>   putchar('\n');
> + if (show_join)
> + join_status();
>   if (shownet80211chans)
>   ieee80211_listchans();
>   else if (shownet80211nodes)
>   ieee80211_listnodes();
>  }
>  
> +void
> +join_status(void)
> +{
> + struct ieee80211_joinreq_all ja;
> + struct ieee80211_join *jn = NULL;
> + int jsz = IEEE80211_CACHE_SIZE;
> + int ojsz;
> + int i;
> + int r;
> +
> + bzero(&ja, sizeof(ja));
> + jn = recallocarray(NULL, 0, jsz, sizeof(*jn));
> + if (jn == NULL)
> + err(1, "recallocarray");
> + ojsz = jsz;
> + while (1) {
> + ja.ja_node = jn;
> + ja.ja_size = jsz * sizeof(*jn);
> + strlcpy(ja.ja_ifname, name, sizeof(ja.ja_ifname));
> +
> + if ((r = ioctl(s, SIOCG80211JOINALL, &ja)) != 0) {
> + if (errno == E2BIG) {
> + jsz += IEEE80211_CACHE_SIZE;
> + if (jsz > 10*IEEE80211_CACHE_SIZE) {
> + warn("SIOCG80211JOINALL");
> + return;
> + }
> + jn = recallocarray(jn, ojsz, jsz, sizeof(*jn));
> + if (jn == NULL)
> + err(1, "recallocarray");
> + ojsz = jsz;
> + continue;
> + } else if (errno != ENOENT)
> + warn("SIOCG80211JOINALL");
> + return;
> + }
> + break;
> + }
> +
> + if (!ja.ja_nodes)
> + return;
> +
> + fputs("\tjoin:\t", stdout);
> + for (i = 0; i < ja.ja_nodes; i++) {
> + if (i > 0)
> + printf("\t\t");
> + if (jn[i].i_len > IEEE80211_NWID_LEN)
> + jn[i].i_len = IEEE80211_NWID_LEN;
> + print_string(jn[i].i_nwid, jn[i].i_len);
> + putchar('\n');
> + }
> +}
> +
>  void
>  ieee80211_listchans(void)
>  {
> diff --git sys/net80211/ieee80211.h sys/net80211/ieee80211.h
> index d7be80a4562..b02cb7924d3 100644
> --- sys/net80211/ieee80211.h
> +++ sys/net80211/ieee80211.h
> @@ -1023,4 +1023,6 @@ enum ieee80211_htprot {
>   IEEE80211_HTPROT_NONHT_MIXED /* non-HT STA associated to our BSS */
>  };
>  
> +#define IEEE80211_CACHE_SIZE 100
> +
>  #endif /* _NET80211_IEEE80211_H_ */
> diff --git sys/net80211/ieee80211_ioctl.c sys/net80211/ieee80211_ioctl.c
> index 4d6b7eb1b71..b41b4fe09d8 100644
> --- sys/net80211/ieee80211_ioctl.c
> +++ sys/net80211/ieee80211_ioctl.c
> @@ -391,8 +391,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
>   struct ieee80211com *ic = (void *)ifp;
>   struct ifreq *ifr = (struct ifreq *)data;
>   int i, error = 0;
> + size_t len;
>   struct ieee80211_nwid nwid;
>   struct ieee80211_join join;
> + struct ieee80211_joinreq_all *ja;
>   struct ieee80211_ess *ess;
>   struct ieee80211_wpapsk *psk;
>   struct ieee80211_keyavail *ka;
> @@ -488,6 +490,26 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
>   }
>   }
>   break;
> + case SIOCG80211JOINALL:
> + ja = (struct ieee80211_joinreq_all *)data;
> + ja->ja_nodes = len = 0;
> + TAILQ_FOREACH(ess, &ic->ic_ess, ess_next) {
> + if (len + sizeof(struct ieee80211_nodereq) >=
> +    ja->ja_size) {
> + error = E2BIG;
> + break;
> + }
> + memset(&join, 0, sizeof(struct ieee80211_join));
> + join.i_len = ess->esslen;
> + memcpy(&join.i_nwid, ess->essid, join.i_len);
> + error = copyout(&join, &ja->ja_node[ja->ja_nodes],
> +    sizeof(struct ieee80211_nodereq));
> + if (error)
> + break;
> + len += sizeof(struct ieee80211_join);
> + ja->ja_nodes++;
> + }
> + break;
>   case SIOCS80211NWKEY:
>   if ((error = suser(curproc)) != 0)
>   break;
> diff --git sys/net80211/ieee80211_ioctl.h sys/net80211/ieee80211_ioctl.h
> index 9ea74127b22..ea19d8a9550 100644
> --- sys/net80211/ieee80211_ioctl.h
> +++ sys/net80211/ieee80211_ioctl.h
> @@ -275,6 +275,7 @@ struct ieee80211_keyrun {
>  
>  #define SIOCS80211SCAN _IOW('i', 210, struct ifreq)
>  
> +#define SIOCG80211JOINALL _IOWR('i', 218, struct ieee80211_joinreq_all)
>  #define SIOCS80211JOIN _IOWR('i', 255, struct ifreq)
>  #define SIOCG80211JOIN _IOWR('i', 256, struct ifreq)
>  
> @@ -288,6 +289,14 @@ struct ieee80211_join {
>   struct ieee80211_nwkey i_nwkey;
>  };
>  
> +struct ieee80211_joinreq_all {
> + char ja_ifname[IFNAMSIZ];
> + int ja_nodes; /* returned count */
> + size_t ja_size;  /* size of node buffer */
> + struct ieee80211_join *ja_node;  /* allocated node buffer */
> +};
> +
> +
>  #define IEEE80211_JOIN_SHOW 0x01
>  #define IEEE80211_JOIN_FOUND 0x02
>  #define IEEE80211_JOIN_DEL 0x04
> diff --git sys/net80211/ieee80211_node.h sys/net80211/ieee80211_node.h
> index 882df583190..afd9b4ce438 100644
> --- sys/net80211/ieee80211_node.h
> +++ sys/net80211/ieee80211_node.h
> @@ -39,7 +39,7 @@
>  #define IEEE80211_TRANS_WAIT 5 /* transition wait */
>  #define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */
>  #define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT)
> -#define IEEE80211_CACHE_SIZE 100
> +
>  #define IEEE80211_CACHE_WAIT 30
>  
>  struct ieee80211_rateset {
>

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Klemens Nanni-2
On Sat, Aug 04, 2018 at 09:03:16PM +0100, Jason McIntyre wrote:
> this is what the man page says we already do (not that i've tested it).
> i'm sure peter told me that's what running it without an argument does.
ifconfig(8) says so, but it's not working:

        $ doas fgrep -c join /etc/hostname.iwm0
        4
        $ ifconfig iwm0 join | fgrep -c join
        1

The output is equivalent to `ifconfig <if>'.

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Jason McIntyre-2
On Sat, Aug 04, 2018 at 10:26:41PM +0200, Klemens Nanni wrote:

> On Sat, Aug 04, 2018 at 09:03:16PM +0100, Jason McIntyre wrote:
> > this is what the man page says we already do (not that i've tested it).
> > i'm sure peter told me that's what running it without an argument does.
> ifconfig(8) says so, but it's not working:
>
> $ doas fgrep -c join /etc/hostname.iwm0
> 4
> $ ifconfig iwm0 join | fgrep -c join
> 1
>
> The output is equivalent to `ifconfig <if>'.
>

ah. in that case, i'm all for the diff!
jmc

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Florian Obser
In reply to this post by Sebastian Benoit-3
OK florian@

On Sat, Aug 04, 2018 at 09:12:27PM +0200, Sebastian Benoit wrote:

> Hi,
>
> with this diff,
>
>   ifconfig <if> join
>
> will print the list of networks that are configured for autojoin.
>
> $ ifconfig iwm0 join
> iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
>         lladdr a4:7f:da:a4:d7:c1
>         index 1 priority 4 llprio 3
>         groups: wlan egress
>         media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
>         status: active
>         ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
>         join:   gesamtkunstwerk
>                 fn0rd
>                 Gaeste
>                 WLAN
>
>
> comments? oks?
>
> (benno_join_list_5.diff)
>
> diff --git sbin/ifconfig/ifconfig.c sbin/ifconfig/ifconfig.c
> index 9bfb1751aab..de6aabf4fba 100644
> --- sbin/ifconfig/ifconfig.c
> +++ sbin/ifconfig/ifconfig.c
> @@ -163,6 +163,7 @@ int newaddr = 0;
>  int af = AF_INET;
>  int explicit_prefix = 0;
>  int Lflag = 1;
> +int show_join = 0;
>  
>  int showmediaflag;
>  int showcapsflag;
> @@ -633,6 +634,7 @@ void in6_status(int);
>  void in6_getaddr(const char *, int);
>  void in6_getprefix(const char *, int);
>  void ieee80211_status(void);
> +void join_status(void);
>  void ieee80211_listchans(void);
>  void ieee80211_listnodes(void);
>  void ieee80211_printnode(struct ieee80211_nodereq *);
> @@ -1656,7 +1658,7 @@ setifjoin(const char *val, int d)
>   int len;
>  
>   if (val == NULL) {
> - /* TODO: display the list of join'd networks */
> + show_join = 1;
>   return;
>   }
>  
> @@ -2292,14 +2294,68 @@ ieee80211_status(void)
>   putchar(' ');
>   printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
>   }
> -
>   putchar('\n');
> + if (show_join)
> + join_status();
>   if (shownet80211chans)
>   ieee80211_listchans();
>   else if (shownet80211nodes)
>   ieee80211_listnodes();
>  }
>  
> +void
> +join_status(void)
> +{
> + struct ieee80211_joinreq_all ja;
> + struct ieee80211_join *jn = NULL;
> + int jsz = IEEE80211_CACHE_SIZE;
> + int ojsz;
> + int i;
> + int r;
> +
> + bzero(&ja, sizeof(ja));
> + jn = recallocarray(NULL, 0, jsz, sizeof(*jn));
> + if (jn == NULL)
> + err(1, "recallocarray");
> + ojsz = jsz;
> + while (1) {
> + ja.ja_node = jn;
> + ja.ja_size = jsz * sizeof(*jn);
> + strlcpy(ja.ja_ifname, name, sizeof(ja.ja_ifname));
> +
> + if ((r = ioctl(s, SIOCG80211JOINALL, &ja)) != 0) {
> + if (errno == E2BIG) {
> + jsz += IEEE80211_CACHE_SIZE;
> + if (jsz > 10*IEEE80211_CACHE_SIZE) {
> + warn("SIOCG80211JOINALL");
> + return;
> + }
> + jn = recallocarray(jn, ojsz, jsz, sizeof(*jn));
> + if (jn == NULL)
> + err(1, "recallocarray");
> + ojsz = jsz;
> + continue;
> + } else if (errno != ENOENT)
> + warn("SIOCG80211JOINALL");
> + return;
> + }
> + break;
> + }
> +
> + if (!ja.ja_nodes)
> + return;
> +
> + fputs("\tjoin:\t", stdout);
> + for (i = 0; i < ja.ja_nodes; i++) {
> + if (i > 0)
> + printf("\t\t");
> + if (jn[i].i_len > IEEE80211_NWID_LEN)
> + jn[i].i_len = IEEE80211_NWID_LEN;
> + print_string(jn[i].i_nwid, jn[i].i_len);
> + putchar('\n');
> + }
> +}
> +
>  void
>  ieee80211_listchans(void)
>  {
> diff --git sys/net80211/ieee80211.h sys/net80211/ieee80211.h
> index d7be80a4562..b02cb7924d3 100644
> --- sys/net80211/ieee80211.h
> +++ sys/net80211/ieee80211.h
> @@ -1023,4 +1023,6 @@ enum ieee80211_htprot {
>   IEEE80211_HTPROT_NONHT_MIXED /* non-HT STA associated to our BSS */
>  };
>  
> +#define IEEE80211_CACHE_SIZE 100
> +
>  #endif /* _NET80211_IEEE80211_H_ */
> diff --git sys/net80211/ieee80211_ioctl.c sys/net80211/ieee80211_ioctl.c
> index 4d6b7eb1b71..b41b4fe09d8 100644
> --- sys/net80211/ieee80211_ioctl.c
> +++ sys/net80211/ieee80211_ioctl.c
> @@ -391,8 +391,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
>   struct ieee80211com *ic = (void *)ifp;
>   struct ifreq *ifr = (struct ifreq *)data;
>   int i, error = 0;
> + size_t len;
>   struct ieee80211_nwid nwid;
>   struct ieee80211_join join;
> + struct ieee80211_joinreq_all *ja;
>   struct ieee80211_ess *ess;
>   struct ieee80211_wpapsk *psk;
>   struct ieee80211_keyavail *ka;
> @@ -488,6 +490,26 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
>   }
>   }
>   break;
> + case SIOCG80211JOINALL:
> + ja = (struct ieee80211_joinreq_all *)data;
> + ja->ja_nodes = len = 0;
> + TAILQ_FOREACH(ess, &ic->ic_ess, ess_next) {
> + if (len + sizeof(struct ieee80211_nodereq) >=
> +    ja->ja_size) {
> + error = E2BIG;
> + break;
> + }
> + memset(&join, 0, sizeof(struct ieee80211_join));
> + join.i_len = ess->esslen;
> + memcpy(&join.i_nwid, ess->essid, join.i_len);
> + error = copyout(&join, &ja->ja_node[ja->ja_nodes],
> +    sizeof(struct ieee80211_nodereq));
> + if (error)
> + break;
> + len += sizeof(struct ieee80211_join);
> + ja->ja_nodes++;
> + }
> + break;
>   case SIOCS80211NWKEY:
>   if ((error = suser(curproc)) != 0)
>   break;
> diff --git sys/net80211/ieee80211_ioctl.h sys/net80211/ieee80211_ioctl.h
> index 9ea74127b22..ea19d8a9550 100644
> --- sys/net80211/ieee80211_ioctl.h
> +++ sys/net80211/ieee80211_ioctl.h
> @@ -275,6 +275,7 @@ struct ieee80211_keyrun {
>  
>  #define SIOCS80211SCAN _IOW('i', 210, struct ifreq)
>  
> +#define SIOCG80211JOINALL _IOWR('i', 218, struct ieee80211_joinreq_all)
>  #define SIOCS80211JOIN _IOWR('i', 255, struct ifreq)
>  #define SIOCG80211JOIN _IOWR('i', 256, struct ifreq)
>  
> @@ -288,6 +289,14 @@ struct ieee80211_join {
>   struct ieee80211_nwkey i_nwkey;
>  };
>  
> +struct ieee80211_joinreq_all {
> + char ja_ifname[IFNAMSIZ];
> + int ja_nodes; /* returned count */
> + size_t ja_size;  /* size of node buffer */
> + struct ieee80211_join *ja_node;  /* allocated node buffer */
> +};
> +
> +
>  #define IEEE80211_JOIN_SHOW 0x01
>  #define IEEE80211_JOIN_FOUND 0x02
>  #define IEEE80211_JOIN_DEL 0x04
> diff --git sys/net80211/ieee80211_node.h sys/net80211/ieee80211_node.h
> index 882df583190..afd9b4ce438 100644
> --- sys/net80211/ieee80211_node.h
> +++ sys/net80211/ieee80211_node.h
> @@ -39,7 +39,7 @@
>  #define IEEE80211_TRANS_WAIT 5 /* transition wait */
>  #define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */
>  #define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT)
> -#define IEEE80211_CACHE_SIZE 100
> +
>  #define IEEE80211_CACHE_WAIT 30
>  
>  struct ieee80211_rateset {
>

--
I'm not entirely sure you are real.

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Stefan Sperling-8
In reply to this post by Sebastian Benoit-3
On Sat, Aug 04, 2018 at 09:12:27PM +0200, Sebastian Benoit wrote:

> Hi,
>
> with this diff,
>
>   ifconfig <if> join
>
> will print the list of networks that are configured for autojoin.
>
> $ ifconfig iwm0 join
> iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
>         lladdr a4:7f:da:a4:d7:c1
>         index 1 priority 4 llprio 3
>         groups: wlan egress
>         media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
>         status: active
>         ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
>         join:   gesamtkunstwerk
>                 fn0rd
>                 Gaeste
>                 WLAN
>
>
> comments? oks?

Could we keep IEEE80211_CACHE_SIZE where it is, and add another
constant (e.g. IEEE80211_JOIN_MAX) to ieee80211_ioctl.h instead?

Both values are actually independent. The join list could be
made larger than the node cache (which represents the list of
currently visible APs).

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Florian Obser-2
On Mon, Aug 06, 2018 at 11:31:27AM +0200, Stefan Sperling wrote:

> On Sat, Aug 04, 2018 at 09:12:27PM +0200, Sebastian Benoit wrote:
> > Hi,
> >
> > with this diff,
> >
> >   ifconfig <if> join
> >
> > will print the list of networks that are configured for autojoin.
> >
> > $ ifconfig iwm0 join
> > iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
> >         lladdr a4:7f:da:a4:d7:c1
> >         index 1 priority 4 llprio 3
> >         groups: wlan egress
> >         media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
> >         status: active
> >         ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
> >         join:   gesamtkunstwerk
> >                 fn0rd
> >                 Gaeste
> >                 WLAN
> >
> >
> > comments? oks?
>
> Could we keep IEEE80211_CACHE_SIZE where it is, and add another
> constant (e.g. IEEE80211_JOIN_MAX) to ieee80211_ioctl.h instead?
>
> Both values are actually independent. The join list could be
> made larger than the node cache (which represents the list of
> currently visible APs).
>

I don't understand why we have a limit on the join list. It's the
users decision to drive their kernel out of memory.

--
I'm not entirely sure you are real.

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Stefan Sperling-8
On Mon, Aug 06, 2018 at 11:42:51AM +0200, Florian Obser wrote:
> I don't understand why we have a limit on the join list.

The ioctl interface is easier to deal with if the max size is known in
advance. The recalloc dance in benno's diff isn't actually necessary
(nevermind that it's still enforcing some other arbitrary limit of ten
times the node cache size).

The current limit seems to be too low for some people. I'd suggest
we just keep bumping it up until people stop complaining.

> It's the users decision to drive their kernel out of memory.

But it's also not a great idea to deliberately allow userspace to do that.
I don't see why this list should be allowed to run the kernel out of memory.

Having some fixed size limit also helps if we decide to add another
persistent storage solution later on. AFAIK this is still being debated.

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Florian Obser-2
On Mon, Aug 06, 2018 at 12:05:30PM +0200, Stefan Sperling wrote:

> On Mon, Aug 06, 2018 at 11:42:51AM +0200, Florian Obser wrote:
> > I don't understand why we have a limit on the join list.
>
> The ioctl interface is easier to deal with if the max size is known in
> advance. The recalloc dance in benno's diff isn't actually necessary
> (nevermind that it's still enforcing some other arbitrary limit of ten
> times the node cache size).
>
> The current limit seems to be too low for some people. I'd suggest
> we just keep bumping it up until people stop complaining.

Well, I disagree, but no matter, I said my piece and will not argue
this further.

Anyway, we have bigger fish to fry. For example telling userland that
we hit the limit and not just silently ignore it...

>
> > It's the users decision to drive their kernel out of memory.
>
> But it's also not a great idea to deliberately allow userspace to do that.
> I don't see why this list should be allowed to run the kernel out of memory.
>
> Having some fixed size limit also helps if we decide to add another
> persistent storage solution later on. AFAIK this is still being debated.
>

--
I'm not entirely sure you are real.

Reply | Threaded
Open this post in threaded view
|

Re: ifconfig <if> join: show list of configured ess ids

Todd T. Fries-2
In reply to this post by Sebastian Benoit-3
Always consider ramdisk builds after adding code to ifconfig not inside
SMALL.

Thanks,

Penned by Sebastian Benoit on 20180804 14:12.27, we have:
| Hi,
|
| with this diff,
|
|   ifconfig <if> join
|
| will print the list of networks that are configured for autojoin.
|
| $ ifconfig iwm0 join
| iwm0: flags=208843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,AUTOCONF6> mtu 1500
|         lladdr a4:7f:da:a4:d7:c1
|         index 1 priority 4 llprio 3
|         groups: wlan egress
|         media: IEEE802.11 autoselect (HT-MCS12 mode 11n)
|         status: active
|         ieee80211: join fn0rd chan 6 bssid 62:62:b5:d3:56:a7 62% wpakey wpaprotos wpa2 wpaakms psk wpaciphers ccmp wpagroupcipher ccmp
|         join:   gesamtkunstwerk
|                 fn0rd
|                 Gaeste
|                 WLAN
|
|
| comments? oks?
|
| (benno_join_list_5.diff)
|
| diff --git sbin/ifconfig/ifconfig.c sbin/ifconfig/ifconfig.c
| index 9bfb1751aab..de6aabf4fba 100644
| --- sbin/ifconfig/ifconfig.c
| +++ sbin/ifconfig/ifconfig.c
| @@ -163,6 +163,7 @@ int newaddr = 0;
|  int af = AF_INET;
|  int explicit_prefix = 0;
|  int Lflag = 1;
| +int show_join = 0;
|  
|  int showmediaflag;
|  int showcapsflag;
| @@ -633,6 +634,7 @@ void in6_status(int);
|  void in6_getaddr(const char *, int);
|  void in6_getprefix(const char *, int);
|  void ieee80211_status(void);
| +void join_status(void);
|  void ieee80211_listchans(void);
|  void ieee80211_listnodes(void);
|  void ieee80211_printnode(struct ieee80211_nodereq *);
| @@ -1656,7 +1658,7 @@ setifjoin(const char *val, int d)
|   int len;
|  
|   if (val == NULL) {
| - /* TODO: display the list of join'd networks */
| + show_join = 1;
|   return;
|   }
|  
| @@ -2292,14 +2294,68 @@ ieee80211_status(void)
|   putchar(' ');
|   printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
|   }
| -
|   putchar('\n');
| + if (show_join)
| + join_status();
|   if (shownet80211chans)
|   ieee80211_listchans();
|   else if (shownet80211nodes)
|   ieee80211_listnodes();
|  }
|  
| +void
| +join_status(void)
| +{
| + struct ieee80211_joinreq_all ja;
| + struct ieee80211_join *jn = NULL;
| + int jsz = IEEE80211_CACHE_SIZE;
| + int ojsz;
| + int i;
| + int r;
| +
| + bzero(&ja, sizeof(ja));
| + jn = recallocarray(NULL, 0, jsz, sizeof(*jn));
| + if (jn == NULL)
| + err(1, "recallocarray");
| + ojsz = jsz;
| + while (1) {
| + ja.ja_node = jn;
| + ja.ja_size = jsz * sizeof(*jn);
| + strlcpy(ja.ja_ifname, name, sizeof(ja.ja_ifname));
| +
| + if ((r = ioctl(s, SIOCG80211JOINALL, &ja)) != 0) {
| + if (errno == E2BIG) {
| + jsz += IEEE80211_CACHE_SIZE;
| + if (jsz > 10*IEEE80211_CACHE_SIZE) {
| + warn("SIOCG80211JOINALL");
| + return;
| + }
| + jn = recallocarray(jn, ojsz, jsz, sizeof(*jn));
| + if (jn == NULL)
| + err(1, "recallocarray");
| + ojsz = jsz;
| + continue;
| + } else if (errno != ENOENT)
| + warn("SIOCG80211JOINALL");
| + return;
| + }
| + break;
| + }
| +
| + if (!ja.ja_nodes)
| + return;
| +
| + fputs("\tjoin:\t", stdout);
| + for (i = 0; i < ja.ja_nodes; i++) {
| + if (i > 0)
| + printf("\t\t");
| + if (jn[i].i_len > IEEE80211_NWID_LEN)
| + jn[i].i_len = IEEE80211_NWID_LEN;
| + print_string(jn[i].i_nwid, jn[i].i_len);
| + putchar('\n');
| + }
| +}
| +
|  void
|  ieee80211_listchans(void)
|  {
| diff --git sys/net80211/ieee80211.h sys/net80211/ieee80211.h
| index d7be80a4562..b02cb7924d3 100644
| --- sys/net80211/ieee80211.h
| +++ sys/net80211/ieee80211.h
| @@ -1023,4 +1023,6 @@ enum ieee80211_htprot {
|   IEEE80211_HTPROT_NONHT_MIXED /* non-HT STA associated to our BSS */
|  };
|  
| +#define IEEE80211_CACHE_SIZE 100
| +
|  #endif /* _NET80211_IEEE80211_H_ */
| diff --git sys/net80211/ieee80211_ioctl.c sys/net80211/ieee80211_ioctl.c
| index 4d6b7eb1b71..b41b4fe09d8 100644
| --- sys/net80211/ieee80211_ioctl.c
| +++ sys/net80211/ieee80211_ioctl.c
| @@ -391,8 +391,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|   struct ieee80211com *ic = (void *)ifp;
|   struct ifreq *ifr = (struct ifreq *)data;
|   int i, error = 0;
| + size_t len;
|   struct ieee80211_nwid nwid;
|   struct ieee80211_join join;
| + struct ieee80211_joinreq_all *ja;
|   struct ieee80211_ess *ess;
|   struct ieee80211_wpapsk *psk;
|   struct ieee80211_keyavail *ka;
| @@ -488,6 +490,26 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|   }
|   }
|   break;
| + case SIOCG80211JOINALL:
| + ja = (struct ieee80211_joinreq_all *)data;
| + ja->ja_nodes = len = 0;
| + TAILQ_FOREACH(ess, &ic->ic_ess, ess_next) {
| + if (len + sizeof(struct ieee80211_nodereq) >=
| +    ja->ja_size) {
| + error = E2BIG;
| + break;
| + }
| + memset(&join, 0, sizeof(struct ieee80211_join));
| + join.i_len = ess->esslen;
| + memcpy(&join.i_nwid, ess->essid, join.i_len);
| + error = copyout(&join, &ja->ja_node[ja->ja_nodes],
| +    sizeof(struct ieee80211_nodereq));
| + if (error)
| + break;
| + len += sizeof(struct ieee80211_join);
| + ja->ja_nodes++;
| + }
| + break;
|   case SIOCS80211NWKEY:
|   if ((error = suser(curproc)) != 0)
|   break;
| diff --git sys/net80211/ieee80211_ioctl.h sys/net80211/ieee80211_ioctl.h
| index 9ea74127b22..ea19d8a9550 100644
| --- sys/net80211/ieee80211_ioctl.h
| +++ sys/net80211/ieee80211_ioctl.h
| @@ -275,6 +275,7 @@ struct ieee80211_keyrun {
|  
|  #define SIOCS80211SCAN _IOW('i', 210, struct ifreq)
|  
| +#define SIOCG80211JOINALL _IOWR('i', 218, struct ieee80211_joinreq_all)
|  #define SIOCS80211JOIN _IOWR('i', 255, struct ifreq)
|  #define SIOCG80211JOIN _IOWR('i', 256, struct ifreq)
|  
| @@ -288,6 +289,14 @@ struct ieee80211_join {
|   struct ieee80211_nwkey i_nwkey;
|  };
|  
| +struct ieee80211_joinreq_all {
| + char ja_ifname[IFNAMSIZ];
| + int ja_nodes; /* returned count */
| + size_t ja_size;  /* size of node buffer */
| + struct ieee80211_join *ja_node;  /* allocated node buffer */
| +};
| +
| +
|  #define IEEE80211_JOIN_SHOW 0x01
|  #define IEEE80211_JOIN_FOUND 0x02
|  #define IEEE80211_JOIN_DEL 0x04
| diff --git sys/net80211/ieee80211_node.h sys/net80211/ieee80211_node.h
| index 882df583190..afd9b4ce438 100644
| --- sys/net80211/ieee80211_node.h
| +++ sys/net80211/ieee80211_node.h
| @@ -39,7 +39,7 @@
|  #define IEEE80211_TRANS_WAIT 5 /* transition wait */
|  #define IEEE80211_INACT_WAIT 5 /* inactivity timer interval */
|  #define IEEE80211_INACT_MAX (300/IEEE80211_INACT_WAIT)
| -#define IEEE80211_CACHE_SIZE 100
| +
|  #define IEEE80211_CACHE_WAIT 30
|  
|  struct ieee80211_rateset {

--
Todd T. Fries . http://todd.fries.net/pgp.txt . @unix2mars . github:toddfries