Newer
Older
fh->include_sta_stats =
atoi(tb[FH_INCLUDE_STA_STATS]->v.string);
if (tb[FH_INCLUDE_STA_METRIC])
fh->include_sta_metric =
atoi(tb[FH_INCLUDE_STA_METRIC]->v.string);
static int agent_config_get_steer_param(struct agent_config *a,
struct uci_section *s)
{
struct steer_rule *r;
dbg("Steer-param: %s\n", s->e.name);
r = get_steer_rule_by_name(s->e.name);
if (!r)
return -1;
dbg("Rule to handle steer-param '%s' available\n", s->e.name);
r->config(r, a, s);
return 0;
}
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
static int agent_config_get_policy_param(struct agent_config *a,
struct uci_section *s)
{
enum {
POL_REPORT_INTERVAL,
POL_PVID,
POL_PCP_DEFAULT,
POL_REPORT_SCAN,
POL_REPORT_STA_ASSOCFAILS,
POL_REPORT_STA_ASSOCFAILS_RATE,
NUM_POLICIES
};
const struct uci_parse_option opts[] = {
{ .name = "report_interval", .type = UCI_TYPE_STRING },
{ .name = "pvid", .type = UCI_TYPE_STRING },
{ .name = "pcp_default", .type = UCI_TYPE_STRING },
{ .name = "repost_scan", .type = UCI_TYPE_STRING },
{ .name = "report_sta_assocfails", .type = UCI_TYPE_STRING },
{ .name = "report_sta_assocfails_rate", .type = UCI_TYPE_STRING },
};
struct uci_option *tb[NUM_POLICIES];
struct policy_cfg *cfg;
uci_parse_section(s, opts, NUM_POLICIES, tb);
cfg = (struct policy_cfg *)calloc(1, sizeof(struct policy_cfg));
if (!cfg)
return -1;
if (tb[POL_REPORT_INTERVAL])
cfg->report_interval = atoi(tb[POL_REPORT_INTERVAL]->v.string);
if (tb[POL_PVID])
cfg->pvid = atoi(tb[POL_PVID]->v.string);
if (tb[POL_PCP_DEFAULT])
cfg->pcp_default = atoi(tb[POL_PCP_DEFAULT]->v.string);
if (tb[POL_REPORT_SCAN])
cfg->report_scan = atoi(tb[POL_REPORT_SCAN]->v.string);
if (tb[POL_REPORT_STA_ASSOCFAILS])
cfg->report_sta_assocfails =
atoi(tb[POL_REPORT_STA_ASSOCFAILS]->v.string);
if (tb[POL_REPORT_STA_ASSOCFAILS_RATE])
cfg->report_sta_assocfails_rate =
atoi(tb[POL_REPORT_STA_ASSOCFAILS_RATE]->v.string);
if (a->pcfg)
free(a->pcfg);
a->pcfg = cfg;
return 0;
}
int agent_config_reload(struct agent_config *cfg)
{
struct uci_context *ctx;
struct uci_package *pkg;
struct uci_element *e;
cfg->enabled = false;
cfg->runfreq = AGENT_RUN_AUTO;
ctx = uci_alloc_context();
if (!ctx)
return -1;
Jakob Olsson
committed
if (uci_load(ctx, "mapagent", &pkg)) {
uci_free_context(ctx);
return -1;
}
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
Jakob Olsson
committed
if (!strcmp(s->type, "agent"))
else if (!strcmp(s->type, "controller_select"))
agent_config_get_controller_select(cfg, s);
else if (!strcmp(s->type, "wifi-radio"))
agent_config_get_wifi_radio(cfg, s);
else if (!strcmp(s->type, "policy"))
agent_config_get_policy_param(cfg, s);
}
uci_free_context(ctx);
return 0;
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
int config_generate_radio(struct agent_config *cfg, struct uci_context *ctx,
char *device, uint8_t band)
{
struct uci_package *pkg;
struct uci_section *s;
int rv;
rv = uci_load(ctx, UCI_AGENT, &pkg);
if (rv)
return -1;
s = config_add_section(ctx, pkg, UCI_AGENT, "wifi-radio", "device",
device);
if (!s)
return -1;
if (band == BAND_2)
set_value(ctx, pkg, s, "band", "2", UCI_TYPE_STRING);
else if (band == BAND_5)
set_value(ctx, pkg, s, "band", "5", UCI_TYPE_STRING);
uci_commit(ctx, &pkg, false);
uci_unload(ctx, pkg);
return 0;
}
int config_generate_bsta_agent(struct agent_config *cfg, struct uci_context *ctx,
const char *device, const char *ifname,
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
uint8_t band)
{
struct uci_section *s;
struct uci_package *pkg;
int rv;
rv = uci_load(ctx, UCI_AGENT, &pkg);
if (rv)
return -1;
s = config_add_section(ctx, pkg, UCI_AGENT, UCI_BK_AGENT, "device",
device);
if (!s)
return -1;
if (band == BAND_2)
set_value(ctx, pkg, s, "band", "2", UCI_TYPE_STRING);
else if (band == BAND_5)
set_value(ctx, pkg, s, "band", "5", UCI_TYPE_STRING);
set_value(ctx, pkg, s, "ifname", ifname, UCI_TYPE_STRING);
uci_commit(ctx, &pkg, false);
uci_unload(ctx, pkg);
return 0;
}
int config_find_radio(struct agent_config *cfg, struct uci_context *ctx,
char *radio)
{
struct uci_package *pkg;
struct uci_section *s;
struct uci_element *e;
bool found = false;
int rv;
rv = uci_load(ctx, UCI_AGENT, &pkg);
if (rv)
return found;
s = config_get_section(ctx, pkg, "wifi-radio", "device", radio);
if (s)
found = true;
uci_unload(ctx, pkg);
return found;
}
static void wifi_radio_status_cb(struct ubus_request *req, int type,
struct blob_attr *msg)
{
struct blob_attr *tb[1];
static const struct blobmsg_policy ap_attr[1] = {
[0] = { .name = "band", .type = BLOBMSG_TYPE_STRING },
};
char band_str[8] = {0};
uint8_t *band = req->priv;
blobmsg_parse(ap_attr, 1, tb, blob_data(msg), blob_len(msg));
if (!tb[0])
return;
strncpy(band_str, blobmsg_data(tb[0]), sizeof(band_str));
if (!strncmp(band_str, "5GHz", sizeof(band_str)))
*band = BAND_5;
else if (!strncmp(band_str, "2.4GHz", sizeof(band_str)))
*band = BAND_2;
else
*band = BAND_UNKNOWN;
}
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
void config_disable_bstas(struct agent_config *cfg)
{
struct uci_context *ctx = NULL;
struct uci_package *pkg;
struct uci_section *section;
struct netif_bkcfg *bk;
bool reload = false;
list_for_each_entry(bk, &cfg->bklist, list) {
/* only disable onboarded bsta */
// if (!bk->cfg->onboarded)
// continue;
/* disable from wireless config */
pkg = uci_load_pkg(&ctx, UCI_WIRELESS);
if (!pkg)
continue;
section = config_get_section(ctx, pkg, UCI_WLAN_IFACE, "ifname", bk->name);
if (!section) {
uci_unload(ctx, pkg);
continue;
}
set_value(ctx, pkg, section, "disabled", "1", UCI_TYPE_STRING);
uci_save(ctx, pkg);
reload = true;
}
if (reload) {
uci_commit(ctx, &pkg, false);
uci_unload(ctx, pkg);
}
list_for_each_entry(bk, &cfg->bklist, list) {
pkg = uci_load_pkg(&ctx, UCI_AGENT);
if (!pkg)
continue;
section = config_get_section(ctx, pkg, UCI_BK_AGENT, "ifname", bk->name);
if (!section) {
uci_unload(ctx, pkg);
continue;
}
set_value(ctx, pkg, section, "enabled", "0", UCI_TYPE_STRING);
uci_save(ctx, pkg);
bk->enabled = 0;
}
if (reload) {
uci_commit(ctx, &pkg, false);
uci_reload_services("wireless");
}
uci_free_context(ctx);
}
int config_disable_bsta(struct netif_bkcfg *bk)
{
struct uci_context *ctx = NULL;
struct uci_package *pkg;
struct uci_section *section;
int ret = -1;
/* disable mapagent bk-iface section */
pkg = uci_load_pkg(&ctx, UCI_AGENT);
if (!pkg)
return -1;
section = config_get_section(ctx, pkg, UCI_BK_AGENT, "ifname", bk->name);
if (!section)
goto out_pkg;
set_value(ctx, pkg, section, "enabled", "0", UCI_TYPE_STRING);
uci_save(ctx, pkg);
bk->enabled = 0;
uci_commit(ctx, &pkg, false);
uci_unload(ctx, pkg);
/* disable wireless config bsta wifi-iface section */
pkg = uci_load_pkg(&ctx, UCI_WIRELESS);
if (!pkg)
goto out;
section = config_get_section(ctx, pkg, UCI_WLAN_IFACE, "ifname", bk->name);
if (!section)
goto out_pkg;
set_value(ctx, pkg, section, "disabled", "1", UCI_TYPE_STRING);
uci_save(ctx, pkg);
uci_commit(ctx, &pkg, false);
ret = 0;
out_pkg:
uci_unload(ctx, pkg);
out:
uci_free_context(ctx);
return ret;
}
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
bool config_find_bsta_agent(struct agent_config *cfg, struct uci_context *ctx,
char *device)
{
struct uci_package *pkg;
struct uci_element *e;
struct uci_section *section = NULL;
int rv;
bool found = false;
rv = uci_load(ctx, UCI_AGENT, &pkg);
if (rv)
return found;
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
char *c_device;
if (strncmp(s->type, UCI_BK_AGENT, strlen(UCI_BK_AGENT)))
continue;
c_device = uci_lookup_option_string(ctx, s, "device");
if (!c_device)
continue;
if (strncmp(device, c_device, 16))
continue;
found = true;
break;
}
uci_unload(ctx, pkg);
return found;
}
struct uci_section *config_find_bsta_wireless(struct agent_config *cfg,
struct uci_context *ctx, struct uci_package *pkg, const char *device)
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
{
struct uci_element *e;
int rv;
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
char *c_device, *mode;
if (strncmp(s->type, UCI_WLAN_IFACE, strlen(UCI_WLAN_IFACE)))
continue;
c_device = uci_lookup_option_string(ctx, s, "device");
if (!c_device || strncmp(device, c_device, 16))
continue;
mode = uci_lookup_option_string(ctx, s, "mode");
if (!mode || strcmp(mode, "sta"))
continue;
return s;
}
return NULL;
}
int agent_config_prepare(struct agent_config *cfg)
{
// TODO: iterate through 'wifi-device' sections in wireless config.
// If corresponding 'wifi-radio <device-name>' section is not available
// in 'mapagent' config, create one. Check supported bands of the new
// wifi-device and add option 'band' to the wifi-radio section.
struct uci_context *ctx = NULL;
struct uci_package *pkg;
struct uci_element *e;
struct blob_buf bb = {0};
pkg = uci_load_pkg(&ctx, UCI_WIRELESS);
if (!pkg)
return -1;
blob_buf_init(&bb, 0);
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
struct uci_section *wl_s;
const char *device, *ifname;
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
uint8_t band = 0;
char obj_name[64] = {0};
int rv;
if (strncmp(s->type, UCI_WL_DEVICE, strlen(UCI_WL_DEVICE)))
continue;
device = s->e.name;
snprintf(obj_name, sizeof(obj_name), "wifi.radio.%s",
device);
rv = ubus_call(obj_name, "status", &bb,
wifi_radio_status_cb, &band);
if (rv)
continue;
if (!config_find_radio(cfg, ctx, device))
config_generate_radio(cfg, ctx, device, band);
if (config_find_bsta_agent(cfg, ctx, device))
continue;
wl_s = config_find_bsta_wireless(cfg, ctx, pkg, device);
if (!wl_s)
continue;
ifname = uci_lookup_option_string(ctx, wl_s, "ifname");
if (!ifname)
continue;
config_generate_bsta_agent(cfg, ctx, device, ifname, band);
}
blob_buf_free(&bb);
uci_unload(ctx, pkg);
uci_free_context(ctx);
return 0;
}
int agent_config_init(struct agent_config *cfg)
{
INIT_LIST_HEAD(&cfg->fhlist);
INIT_LIST_HEAD(&cfg->bklist);
INIT_LIST_HEAD(&cfg->radiolist);
INIT_LIST_HEAD(&cfg->steer_excludelist);
INIT_LIST_HEAD(&cfg->steer_btm_excludelist);
agent_config_prepare(cfg);
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
agent_config_reload(cfg);
return 0;
}
void clean_bk(struct netif_bkcfg *p)
{
list_del(&p->list);
free(p);
}
int clean_all_bk(struct agent_config *cfg)
{
struct netif_bkcfg *p, *tmp;
list_for_each_entry_safe(p, tmp, &cfg->bklist, list)
clean_bk(p);
return 0;
}
void clean_fh(struct netif_fhcfg *p)
{
list_del(&p->list);
free(p);
}
int clean_all_fh(struct agent_config *cfg)
{
struct netif_fhcfg *p, *tmp;
list_for_each_entry_safe(p, tmp, &cfg->fhlist, list)
clean_fh(p);
return 0;
}
void clean_radio_cfg(struct agent_config_radio *p)
{
list_del(&p->list);
free(p);
}
int clean_all_radios(struct agent_config *cfg)
{
struct agent_config_radio *p, *tmp;
list_for_each_entry_safe(p, tmp, &cfg->radiolist, list)
clean_radio_cfg(p);
return 0;
}
int agent_config_clean(struct agent_config *cfg)
{
clean_all_fh(cfg);
clean_all_bk(cfg);
clean_steer_btm_excl(cfg);
clean_steer_excl(cfg);
if (cfg->pcfg)
free(cfg->pcfg);
int wifi_reorder_interfaces_by_device(struct agent_config *ac,
struct uci_context *ctx, struct uci_package *pkg, char *device)
{
int i, j = 0;
int devnum = 0;
char ifname[IFNAMSIZ] = {0};
enum {
W_IFNAME,
NUM_POLICIES
};
const struct uci_parse_option opts[] = {
{ .name = "ifname", .type = UCI_TYPE_STRING }
};
struct uci_option *tb[NUM_POLICIES];
struct uci_element *e;
dbg("|%s:%d| reordering interfaces for device %s\n", __func__,
__LINE__, device);
devnum = get_device_num_from_name(device);
snprintf(ifname, IFNAMSIZ, "%s%d",
ac->netdev,
devnum);
for (i = 1; i < 16; i++) {
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
if (strncmp(s->type, UCI_WLAN_IFACE,
strlen(UCI_WLAN_IFACE)))
continue;
uci_parse_section(s, opts, NUM_POLICIES, tb);
if (!tb[W_IFNAME])
continue;
if (strncmp(tb[W_IFNAME]->v.string, ifname, sizeof(ifname)))
continue;
dbg("|%s:%d| found interface %s, reordering to %d\n",
__func__, __LINE__, ifname, j);
uci_reorder_section(ctx, s, j);
j++;
break;
}
snprintf(ifname, IFNAMSIZ, "%s%d%s%d",
ac->netdev,
devnum,
(ac->brcm_setup ? "." : "_"),
i);
}
return 0;
}
int wifi_reorder_interfaces(struct agent_config *ac)
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
{
struct uci_context *ctx;
struct uci_package *pkg;
struct uci_element *e;
ctx = uci_alloc_context();
if (!ctx)
return -1;
if (uci_load(ctx, UCI_WIRELESS, &pkg)) {
uci_free_context(ctx);
return -1;
}
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
if (strncmp(s->type, UCI_WL_DEVICE, strlen(UCI_WL_DEVICE)))
continue;
wifi_reorder_interfaces_by_device(ac, ctx, pkg, s->e.name);
}
uci_commit(ctx, &pkg, false);
uci_free_context(ctx);
return 0;
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
}
int uci_set_bridge(char *config, char *bridge, char *proto, char *ipaddress)
{
struct uci_context *ctx = NULL;
struct uci_package *pkg;
struct uci_element *e;
struct uci_section *section = NULL;
/** if bridge starts with br prefix, step past */
if (!strncmp(bridge, "br-", 3))
bridge += 3;
pkg = uci_load_pkg(&ctx, "network");
if (!pkg)
return -1;
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
if (strncmp(s->e.name, bridge, 16))
continue;
section = s;
break;
}
if (!section) {
struct uci_ptr ptr = {0};
ptr.p = pkg;
ptr.section = bridge;
ptr.value = "interface";
ptr.option = NULL;
uci_set(ctx, &ptr);
section = ptr.s;
}
set_value(ctx, pkg, section, "type", "bridge", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "is_lan", "1", UCI_TYPE_STRING);
if (strlen(proto))
set_value(ctx, pkg, section, "proto", proto, UCI_TYPE_STRING);
if (!strcmp(proto, "static")) {
set_value(ctx, pkg, section, "ipaddr", ipaddress,
UCI_TYPE_STRING);
set_value(ctx, pkg, section, "netmask", "255.255.255.0",
UCI_TYPE_STRING);
}
uci_commit(ctx, &pkg, false);
uci_unload(ctx, pkg);
uci_free_context(ctx);
return false;
}
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
int uci_add_dhcp(char *iface)
{
struct uci_context *ctx = NULL;
struct uci_package *pkg;
struct uci_element *e;
struct uci_section *section = NULL;
struct uci_ptr ptr = {0};
/** if bridge starts with br prefix, step past */
if (!strncmp(iface, "br-", 3))
iface += 3;
pkg = uci_load_pkg(&ctx, "dhcp");
if (!pkg)
return -1;
uci_foreach_element(&pkg->sections, e) {
struct uci_section *s = uci_to_section(e);
if (strncmp(s->e.name, iface, 16))
continue;
trace("Existing section found for ifname %s\n", iface);
goto out;
}
trace("Adding DHCP section for ifname %s\n", iface);
ptr.p = pkg;
ptr.section = iface;
ptr.value = "dhcp";
ptr.option = NULL;
uci_set(ctx, &ptr);
section = ptr.s;
set_value(ctx, pkg, section, "interface", iface, UCI_TYPE_STRING);
set_value(ctx, pkg, section, "start", "100", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "limit", "150", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "leasetime", "1h", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "dhcpv6", "server", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "ra", "server", UCI_TYPE_STRING);
uci_commit(ctx, &pkg, false);
out:
uci_unload(ctx, pkg);
uci_free_context(ctx);
return false;
}
int uci_add_fw(struct agent_config *cfg, char *iface)
{
struct uci_context *ctx = NULL;
struct uci_package *pkg;
struct uci_element *e;
struct uci_section *section = NULL;
int rv;
/** if bridge starts with br prefix, step past */
if (!strncmp(iface, "br-", 3))
iface += 3;
pkg = uci_load_pkg(&ctx, "firewall");
if (!pkg)
return -1;
section = config_get_section(ctx, pkg, "zone", "name", iface);
if (!section) {
trace("No fw section found for %s\n", iface);
rv = uci_add_section(ctx, pkg, "zone", §ion);
if (rv)
goto out_pkg;
set_value(ctx, pkg, section, "name", iface, UCI_TYPE_STRING);
set_value(ctx, pkg, section, "network", iface, UCI_TYPE_LIST);
set_value(ctx, pkg, section, "input", "ACCEPT", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "output", "ACCEPT", UCI_TYPE_STRING);
set_value(ctx, pkg, section, "forward", "ACCEPT", UCI_TYPE_STRING);
rv = uci_save(ctx, pkg);
if (rv)
goto out_pkg;
uci_commit(ctx, &pkg, false);
}
section = config_get_section(ctx, pkg, "forwarding", "src", iface);
if (!section) {
//section = config_add_section(ctx, pkg, "firewall", "forwarding", "src", iface);
//if (!section)
// goto out;
rv = uci_add_section(ctx, pkg, "forwarding", §ion);
if (rv)
goto out_pkg;
set_value(ctx, pkg, section, "src", iface, UCI_TYPE_STRING);
set_value(ctx, pkg, section, "dest", cfg->al_bridge, UCI_TYPE_STRING);
uci_commit(ctx, &pkg, false);
}
out_pkg:
uci_unload(ctx, pkg);
uci_free_context(ctx);
return false;
}