Introduce TA WIFI agent library#3
Conversation
631fa7a to
986c493
Compare
|
| rc = te_strtou_size(value, 0, &val, | ||
| sizeof(val)); |
There was a problem hiding this comment.
It can definitely fit into one line.
| if (port == NULL) | ||
| return TE_RC(TE_TA_UNIX, TE_ENOENT); | ||
|
|
||
| port->enable = (atoi(value) > 0) ? true : false; |
|
|
||
| port->enable = (atoi(value) > 0) ? true : false; | ||
|
|
||
| return ta_unix_conf_wifi_apply(); |
There was a problem hiding this comment.
You should implement commit method instead.
| .f = NULL, \ | ||
| .radio_instance = 0, \ | ||
| .iface_instance = 0, \ | ||
| .port = NULL, \ | ||
| .tmpl_data = NULL, \ | ||
| } |
There was a problem hiding this comment.
Misaligned backslashes.
| int n = 0; | ||
| char *tok[3] = {0}; | ||
| char *p; | ||
|
|
||
| p = strtok(line, " \t\r\n"); | ||
| while (p && n < 3) | ||
| { | ||
| if (*p == '\'' && p[strlen(p) - 1] == '\'' && strlen(p) > 1) | ||
| { | ||
| p[strlen(p) - 1] = 0; | ||
| p++; | ||
| } | ||
| tok[n++] = p; | ||
| if (n == 2) | ||
| { | ||
| p = strtok(NULL, "\n"); | ||
| } | ||
| else | ||
| { | ||
| p = strtok(NULL, " \t\r\n"); | ||
| } | ||
| } | ||
|
|
||
| if (n == 3) |
There was a problem hiding this comment.
te_vec_split_string() ?
There was a problem hiding this comment.
Obviously this function is not suitable. I will, however, introduce string->vec tokenizer.
|
Also, we do already have |
| Name: empty | ||
| Value: 0 or 1 | ||
|
|
||
| - oid: "/agent/wifi/port/ifname" |
There was a problem hiding this comment.
This should be related to /agent/interface in some way/
There was a problem hiding this comment.
Rather SSID is related.
There was a problem hiding this comment.
@ol-arteman in general it is not guaranteed that the port would always be mapped to the existing interface. Depending on configurator, it may run it later, making it impossible to bind to.
| Root object of the WiFi configuration tree. | ||
| Name: empty | ||
|
|
||
| - oid: "/agent/wifi/port" |
There was a problem hiding this comment.
I bet it should be a resource.
There was a problem hiding this comment.
also the same problem - it could be non-existing interface and thus we can't bind it easily.
@evengerova please tell what you think.
There was a problem hiding this comment.
Typically PHYs are created on startup and may be really be considered as resources. Of course in theory we can load kernel modules later, but IMHO it's not that probable.
There was a problem hiding this comment.
Ports are indexed by user-friendly name, therefore it is not feasible to add them to resources (ifname might not be the same as the instance name)
| Name: Internal SSID name | ||
|
|
||
| - oid: "/agent/wifi/port/ssid/aname" | ||
| access: read_write | ||
| type: string | ||
| d: | | ||
| SSID name. | ||
| Name: empty | ||
| Value: SSID name |
There was a problem hiding this comment.
Why aname ? And why do we need a SSID name as an attribute if we have a SSID name as a name of an instance?
There was a problem hiding this comment.
Internal SSID name is something we can index SSIDs by, while real SSID name is something that is passed over the air.
| - oid: "/agent/wifi/port/ssid/option" | ||
| access: read_create | ||
| type: none | ||
| d: | | ||
| Additional options passed to underlying configurator. | ||
| Name: any | ||
| Value: none | ||
|
|
||
| - oid: "/agent/wifi/port/ssid/option/value" | ||
| access: read_write | ||
| type: string | ||
| d: | | ||
| Value of the option passed to underlying configurator. | ||
| Name: empty | ||
| Value: any option permitted by underlying configurator. |
There was a problem hiding this comment.
I am kind of skeptic of this design. It pretends to be kind of backend-neutral, but it's actually not - there is absolutely no warrant that all possible wifi configurators can be expressed with a simple option-value scheme. Also, there is no introspection: the testsuite has no way of learning which options are supported.
There was a problem hiding this comment.
There is no fundamentally good solution to the problem of representability. It is up to particular configurator to make this scheme work.
| Root object of the WiFi configuration tree. | ||
| Name: empty | ||
|
|
||
| - oid: "/agent/wifi/configurator" |
There was a problem hiding this comment.
Why is this necessary? Isn't it's possible to do auto-detection?
There was a problem hiding this comment.
It is possible to auto detect, but it is impossible to make wise and reproducible decision with autodetection.
There was a problem hiding this comment.
Why? Let's at least allow to keep this field empty to get auto detection.
| Name: empty | ||
| Value: 0 or 1 | ||
|
|
||
| - oid: "/agent/wifi/port" |
There was a problem hiding this comment.
It's not possible to add a port.
There was a problem hiding this comment.
Indeed it is possible. It is not autodetected from the configuration, and realistically there may be configurators that would run interface afterwards.
| Name: empty | ||
| Value: 0 or 1 | ||
|
|
||
| - oid: "/agent/wifi/port/ifname" |
There was a problem hiding this comment.
Rather SSID is related.
| Name: empty | ||
| Value: Channel number | ||
|
|
||
| - oid: "/agent/wifi/port/htmode" |
There was a problem hiding this comment.
htmode is UCI-specific thing. Ive asked (and Misha has done) channel width - number 20/40/80/160
| Name: empty | ||
| Value: Any supported by Linux | ||
|
|
||
| - oid: "/agent/wifi/port/ssid/aname" |
| d: | | ||
| SSID security. | ||
| Name: empty | ||
| Value: open, wpa, wpa2, wpa3 |
| Name: empty | ||
| Value: Passphrase 8 to 63 characters long | ||
|
|
||
| - oid: "/agent/wifi/port/ssid/option" |
There was a problem hiding this comment.
I do not like OS-specific and hw-specific options. From the other hand it's not quite clear how to get default values for mandatory things.
|
|
||
| /** Supported WiFi standards */ | ||
| typedef enum ta_wifi_standard { | ||
| TA_WIFI_STANDARD_G = 0, /**< G standard (2.4GHz) */ |
There was a problem hiding this comment.
AX and BE are applied for both 2.4 and 5.
|
|
||
| #include "te_queue.h" | ||
|
|
||
| #define MAX_LINE (1024) |
There was a problem hiding this comment.
Just wonder why do we need parser if there is an API (or in the worst case CLI). But, I suppose, it's too late...
There was a problem hiding this comment.
extra dependencies is always a bad idea
Because tapi_wifi is not generic, but operates Linux-specific wpa_supplicant concepts. Also does not support AP. |
6aa84b7 to
90bb9aa
Compare
New and updated commits still do not conform to our Contributor's Guide. There is a script Also I would really appreciate it if fixup commits were squashed into their base commits. |
I didn't say it is ready for a new review (there are several projects that depend on that branch and all of them have to be verified) and I haven't marked your request as processed in any way. |
|
May I also ask for some close-to-real-world examples of an instance tree? |
|
Signed-off-by: Maxim Menshikov <maxim.menshikov@interpretica.io> Acked-by: Elena Vengerova <elena.vengerova@aprocsys.com>
Signed-off-by: Maxim Menshikov <maxim.menshikov@interpretica.io> Acked-by: Elena Vengerova <elena.vengerova@aprocsys.com>
This is the first bit to enable configuration of WiFi - generic definitions that should be used in both tests and the agent implementation. Signed-off-by: Maxim Menshikov <maxim.menshikov@interpretica.io> Acked-by: Elena Vengerova <elena.vengerova@aprocsys.com>
8b708ab to
baf4711
Compare
|
@ol-arteman we may continue this public execution I think. I also merged wpa_supplicant configuration code here. |
There was a problem hiding this comment.
return 0 in NOK case looks wrong for me, wpa_supplicat failed to start,
there is "Failed to start WPA Supplicant" printout
but
"Set /agent:agt_wifi_d/wifi:/enable: = 1"
succeeded and test fails later then it should.
I've looked at another commits,
g 'commit(unsigned int gid' .
they all return rc in NOK case.
There was a problem hiding this comment.
Returning 0 may break TA and it is not what you expect. You should rather check status before continuing.
There was a problem hiding this comment.
Could you elaborate?
0 is returned in NOK case now and I propose to fix it
edea483 to
1e8b669
Compare
TA WiFi is based on several concepts: - It tries to be backend-agnostic. Right now, UCI and wpa_supplicant are supported. - It still supports backend-specific optinons. It is clear that real-world devices require unique options that can't be covered by unified set of options. - The backend is auto-detected by default but can be fixed to one of them. For UCI, there are several implications: - The configuration is first read, then augmented. To generate it correctly, the port interface name must match the one in the configuration. - The SSID configuration is based on the first SSID from the configuration that matches the band of the port. - The configuration must reside in /etc/config/wireless. - The script to up/down the interfaces is 'wifi up'. For wpa_supplicant, the binary must reside in /usr/sbin/wpa_supplicant. For hostapd, the binary must reside in /usr/sbin/hostapd Signed-off-by: Maxim Menshikov <maxim.menshikov@interpretica.io> Acked-by: Elena Vengerova <elena.vengerova@aprocsys.com>
Signed-off-by: Maxim Menshikov <maxim.menshikov@interpretica.io> Acked-by: Elena Vengerova <elena.vengerova@aprocsys.com>
1e8b669 to
fba6d97
Compare
There was a problem hiding this comment.
I don’t know openwrt logic well, but to me, a safer approach is:
- "wifi down" with old /etc/config/wireless
- update /etc/config/wireless
- wifi up
I’m encountering a rare test failure and suspect that the old iface conflicts with the new one.
However, I have no proof, and the issue is quite rare.
There was a problem hiding this comment.
Could you elaborate?
0 is returned in NOK case now and I propose to fix it
There was a problem hiding this comment.
what about txpower, frag, rts, and other test written options?
I suspect they multiply as well e.g.
first run txpower = 10,
second run txpower = 20 and it produces
option txpower 10
option txpower 20
There was a problem hiding this comment.
It is more correct to take ssid's protocol into account
- CHECKED_FPRINTF(ctx->f, "\toption encryption '%s'\n",
- wifi_security2enc[node->security]);
+ CHECKED_FPRINTF(ctx->f, "\toption encryption '%s+%s'\n",
+ wifi_security2enc[node->security],
+ tapi_cfg_wifi_protocol_from_value(node->protocol));
to get psk2+tkip, psk2+ccmp
https://openwrt.org/docs/guide-user/network/wifi/basic#encryption_modes
| } | ||
|
|
||
| /* See the description in tapi_cfg_wifi.h */ | ||
| tapi_cfg_wifi_standard |
There was a problem hiding this comment.
here and in a header
tapi_cfg_wifi_standard -> tapi_cfg_wifi_width
| } | ||
|
|
||
| /* See the description in tapi_cfg_wifi.h */ | ||
| tapi_cfg_wifi_mode |
There was a problem hiding this comment.
here and in a header
tapi_cfg_wifi_mode -> tapi_cfg_wifi_protocol
There are more notes, but I don't remember them,
nobody in the office and bolger with my home offline.
This test agent library adds an ability to set up the WiFi configuration using UCI and hostapd/wpa_supplicant (eventually).
It is based on the design & requirements by Elena V.
The main idea is that there is a very small set of options in the configurator tree. This set of options is merged into the real UCI configuration that is already present on the test host. Then, the "wifi up" is called to restart the network on the device.