Re: [OpenWrt-Devel] uhttpd / startup-error without a message
Hi, this is already fixed in trunk. The uhttpd stderr is relayed to syslog there. ~ Jow ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] uhttpd / startup-error without a message
today I was searching for a non-running uhttpd and recognized, that there are no error messages anymore if something goes wrong. in 62ff68fb / r38023 # procd: convert various packages to procd style init.d scripts # Signed-off-by: John Crispin blo...@openwrt.org the debug-output was commented out. was this intended? (see line 135 in package/network/services/uhttpd/files/uhttpd.init) bye, bastian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] uhttpd / startup-error without a message
* Jo-Philipp Wich j...@openwrt.org [11.05.2015 10:29]: this is already fixed in trunk. The uhttpd stderr is relayed to syslog there. thank you - i see: this is not very intuitive. can this be send to console when user is interactive? (like: loggger -s message) bye, bastian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] uhttpd / startup-error without a message / procd interactive logging
* Jo-Philipp Wich j...@openwrt.org [11.05.2015 11:47]: this is not very intuitive. can this be send to console when user is interactive? (like: loggger -s message) Not easily as it is procd logging the services stderr. One can implement a test or debug start action though which would calculate the commandline and start the daemon in foreground without actually registering it with procd. it think thats too special - there should be a generic way to get direct feedback on the commandline when something fails without doing magic. what if we e.g. 'export INTERACTIVE=1' via /etc/profile so procd / a called script is aware of this? bye, bastian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] uhttpd / startup-error without a message / procd interactive logging
it think thats too special - there should be a generic way to get direct feedback on the commandline when something fails without doing magic. what if we e.g. 'export INTERACTIVE=1' via /etc/profile so procd / a called script is aware of this? Whats too special with /etc/init.d/$SERVICE debug ? Its exactly doing what you'd normally do to hunt down the error - start the service in foreground so you need to kill with Ctrl-C. All messages are sent to the console then (at least in the case of uhttpd or any other service using ulog). ~ Jow ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] uhttpd / startup-error without a message
Hi. thank you - i see: this is not very intuitive. can this be send to console when user is interactive? (like: loggger -s message) Not easily as it is procd logging the services stderr. One can implement a test or debug start action though which would calculate the commandline and start the daemon in foreground without actually registering it with procd. ~ Jow ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] [rpcd][v2] file: add support for base64
On 2015-05-11 00:26, Luka Perkov wrote: Signed-off-by: Luka Perkov l...@openwrt.org --- = changes in v2: Use new libubox base64 provided API. file.c | 118 +++-- 1 file changed, 107 insertions(+), 11 deletions(-) diff --git a/file.c b/file.c index 9c1b301..c3671bb 100644 --- a/file.c +++ b/file.c @@ -182,7 +206,17 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(buf, 0); - wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + if (tb[RPC_F_RB_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RB_BASE64]); + + if (base64) + { + wbuf = blobmsg_alloc_string_buffer(buf, data, B64_ENCODE_LEN(s.st_size)); + } + else + { + wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + } How about using the 'len' variable to avoid duplicating most of the code here. You can also get rid of unnecessary {} lines. @@ -196,14 +230,35 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, goto out; } + if (base64) + { + uint8_t *data = calloc(B64_ENCODE_LEN(len), sizeof(uint8_t)); + if (!data) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } You can reduce allocation/copy size if you copy wbuf to a temporary buffer and then use it as output for b64_encode. + len = b64_encode(wbuf, len, data, B64_ENCODE_LEN(len)); + if (len 0) + { + free(data); + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + + memcpy(wbuf, data, len); + free(data); + } + *(wbuf + len) = 0; blobmsg_add_string_buffer(buf); ubus_send_reply(ctx, req, buf.head); - blob_buf_free(buf); rv = UBUS_STATUS_OK; out: + blob_buf_free(buf); close(fd); return rv; } @@ -222,18 +282,54 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, if (!tb[RPC_F_RW_PATH] || !tb[RPC_F_RW_DATA]) return UBUS_STATUS_INVALID_ARGUMENT; + data = blobmsg_data(tb[RPC_F_RW_DATA]); + data_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; + if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_TRUNC | O_WRONLY, 0666)) 0) return rpc_errno_status(); - if (write(fd, blobmsg_data(tb[RPC_F_RW_DATA]), blobmsg_data_len(tb[RPC_F_RW_DATA])) 0) - return rpc_errno_status(); + if (tb[RPC_F_RW_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RW_BASE64]); + + if (base64) + { + rbuf_len = B64_DECODE_LEN(data_len); + rbuf = calloc(rbuf_len, sizeof(uint8_t)); + if (!rbuf) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + + rbuf_len = b64_decode(data, rbuf, rbuf_len); + if (rbuf_len 0) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + } + else + { + rbuf = data; + rbuf_len = data_len; + } It is safe to overwrite the data area in this function, as long as you don't overstep attribute bounds. This means you can reuse the input buffer as output buffer for b64_decode and get rid of the temporary allocation. - Felix ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] uhttpd / startup-error without a message / procd interactive logging
* Jo-Philipp Wich j...@openwrt.org [11.05.2015 12:34]: it think thats too special - there should be a generic way to get direct feedback on the commandline when something fails without doing magic. what if we e.g. 'export INTERACTIVE=1' via /etc/profile so procd / a called script is aware of this? Whats too special with /etc/init.d/$SERVICE debug ? it has to be implemented for every service - or are you thinking of doing it generic via rc.common? (then I am fine with 'debug') also: if the service fails to start, there should be at least a 'hint-message' to use 'debug'. bye, bastian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [RESEND][PATCH] Fix uninitialised variable causing 1-wire to not bind to GPIO
--- package/kernel/w1-gpio-custom/src/w1-gpio-custom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/package/kernel/w1-gpio-custom/src/w1-gpio-custom.c b/package/kernel/w1-gpio-custom/src/w1-gpio-custom.c index fc2f842..2018f58 100644 --- a/package/kernel/w1-gpio-custom/src/w1-gpio-custom.c +++ b/package/kernel/w1-gpio-custom/src/w1-gpio-custom.c @@ -113,6 +113,7 @@ static int __init w1_gpio_custom_add_one(unsigned int id, unsigned int *params) pdata.pin = params[BUS_PARAM_PIN]; pdata.is_open_drain = params[BUS_PARAM_OD] ? 1 : 0; pdata.enable_external_pullup = NULL; + pdata.ext_pullup_enable_pin = -1; err = platform_device_add_data(pdev, pdata, sizeof(pdata)); if (err) -- 1.9.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] ar71xx: Add support for the Meraki MR12 MR16
Am 09.05.2015 um 18:26 schrieb Chris Blake: This patch is to add support for the Meraki MR12 and MR16 Access Points. Currently everything is working, minus the 2nd NIC interface on the MR12 which is built into the SoC. Signed-off-by: Chris R Blake chrisrblak...@gmail.com Your patch is line wrapped by your mail application. Please resend with git send-mail. Best Christian ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] netifd: Support for configurable default packet steering
On Mon, May 11, 2015 at 9:17 PM, Steven Barth cy...@openwrt.org wrote: Fine with me in principle, howeverI find the name force_ps to be misleading since the option does not override or enforce anything. Maybe default_ps would be a more suitable name? OK will change the name into default_ps in the follow-up patch Hans Cheers, Steven On 11.05.2015 18:30, Hans Dedecker wrote: Default packet steering behavior can be configured via the parameter force_ps in the global section; the default value is true to keep backwards compatibility. Device packet steering (rps/xps) config can still be used to override the default behavior. This allows you to disable packet steering for all devices without the need to define a device config list which disables receive/transmit packet steering Signed-off-by: Hans Dedecker dedec...@gmail.com --- config.c | 6 ++ device.c | 56 +--- device.h | 3 +++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/config.c b/config.c index 48c4fbf..77ebb45 100644 --- a/config.c +++ b/config.c @@ -306,6 +306,12 @@ config_init_globals(void) const char *ula_prefix = uci_lookup_option_string( uci_ctx, globals, ula_prefix); interface_ip_set_ula_prefix(ula_prefix); + + const char *force_ps = uci_lookup_option_string( + uci_ctx, globals, force_ps); + + if (force_ps) + device_set_force_ps(strcmp(force_ps, 1) ? false : true); } static void diff --git a/device.c b/device.c index 092c2d9..afe917c 100644 --- a/device.c +++ b/device.c @@ -29,6 +29,7 @@ #include config.h static struct avl_tree devices; +static bool force_ps = true; static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_TYPE] = { .name = type, .type = BLOBMSG_TYPE_STRING }, @@ -244,15 +245,19 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s-flags |= DEV_OPT_NEIGHREACHABLETIME; } - if ((cur = tb[DEV_ATTR_RPS])) + if ((cur = tb[DEV_ATTR_RPS])) { s-rps = blobmsg_get_bool(cur); + s-flags |= DEV_OPT_RPS; + } else - s-rps = true; + s-rps = force_ps; - if ((cur = tb[DEV_ATTR_XPS])) + if ((cur = tb[DEV_ATTR_XPS])) { s-xps = blobmsg_get_bool(cur); + s-flags |= DEV_OPT_XPS; + } else - s-xps = true; + s-xps = force_ps; device_set_disabled(dev, disabled); } @@ -370,8 +375,8 @@ int device_init(struct device *dev, const struct device_type *type, const char * system_if_clear_state(dev); device_check_state(dev); - dev-settings.rps = true; - dev-settings.xps = true; + dev-settings.rps = force_ps; + dev-settings.xps = force_ps; return 0; } @@ -723,6 +728,41 @@ device_reset_old(void) } } +void +device_set_force_ps(bool state) +{ + struct device *dev; + + if (state == force_ps) + return; + + force_ps = state; + + avl_for_each_element(devices, dev, avl) { + struct device_settings *s = dev-settings; + unsigned int apply_mask = 0; + + if (!(s-flags DEV_OPT_RPS)) { + s-rps = force_ps; + apply_mask |= DEV_OPT_RPS; + } + + if (!(s-flags DEV_OPT_XPS)) { + s-xps = force_ps; + apply_mask |= DEV_OPT_XPS; + } + + if (!apply_mask) + continue; + + if (!(dev-external || (dev-present dev-active)) || + dev-config_pending) + continue; + + system_if_apply_settings(dev, s, apply_mask); + } +} + struct device * device_create(const char *name, const struct device_type *type, struct blob_attr *config) @@ -758,8 +798,10 @@ device_create(const char *name, const struct device_type *type, if (odev) device_replace(dev, odev); - if (!config_init dev-config_pending) + if (!config_init dev-config_pending) { type-config_init(dev); + dev-config_pending = false; + } return dev; } diff --git a/device.h b/device.h index 753e1fa..d80142b 100644 --- a/device.h +++ b/device.h @@ -78,6 +78,8 @@ enum { DEV_OPT_IGMPVERSION = (1 7), DEV_OPT_MLDVERSION = (1 8), DEV_OPT_NEIGHREACHABLETIME = (1 9), + DEV_OPT_RPS = (1 10), + DEV_OPT_XPS = (1 11), }; /* events broadcasted to all users of a device */ @@ -206,6 +208,7 @@
[OpenWrt-Devel] [PATCH] lantiq: Fix PCIe bus when PCI is also enabled.
The PCIe bus seems to require a hack/workaround when PCI is enabled as well. Unfortunately this is guarded by an CONFIG_IFX_PCI ifdef, which is only defined in lantiq's BSP code. The config symbol for the upstream lantiq PCI driver is CONFIG_PCI_LANTIQ. Signed-off-by: Martin Blumenstingl martin.blumensti...@googlemail.com --- .../0001-MIPS-lantiq-add-pcie-driver.patch | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/target/linux/lantiq/patches-3.18/0001-MIPS-lantiq-add-pcie-driver.patch b/target/linux/lantiq/patches-3.18/0001-MIPS-lantiq-add-pcie-driver.patch index 2cc0814..26f262c 100644 --- a/target/linux/lantiq/patches-3.18/0001-MIPS-lantiq-add-pcie-driver.patch +++ b/target/linux/lantiq/patches-3.18/0001-MIPS-lantiq-add-pcie-driver.patch @@ -4115,11 +4115,11 @@ Signed-off-by: John Crispin blo...@openwrt.org +{ +u32 tbus_number = bus_number; + -+#ifdef CONFIG_IFX_PCI ++#ifdef CONFIG_PCI_LANTIQ +if (pcibios_host_nr() 1) { +tbus_number -= pcibios_1st_host_bus_nr(); +} -+#endif /* CONFIG_IFX_PCI */ ++#endif /* CONFIG_PCI_LANTIQ */ +return tbus_number; +} + @@ -4141,14 +4141,14 @@ Signed-off-by: John Crispin blo...@openwrt.org +} + +if (read) { /* Read hack */ -+#ifdef CONFIG_IFX_PCI ++#ifdef CONFIG_PCI_LANTIQ +if (pcibios_host_nr() 1) { +tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue); +} -+#endif /* CONFIG_IFX_PCI */ ++#endif /* CONFIG_PCI_LANTIQ */ +} +else { /* Write hack */ -+#ifdef CONFIG_IFX_PCI ++#ifdef CONFIG_PCI_LANTIQ +if (pcibios_host_nr() 1) { +tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue); +} @@ -5457,11 +5457,11 @@ Signed-off-by: John Crispin blo...@openwrt.org +{ +u32 tbus_number = bus_number; + -+#ifdef CONFIG_IFX_PCI ++#ifdef CONFIG_PCI_LANTIQ +if (pcibios_host_nr() 1) { +tbus_number -= pcibios_1st_host_bus_nr(); +} -+#endif /* CONFIG_IFX_PCI */ ++#endif /* CONFIG_PCI_LANTIQ */ +return tbus_number; +} + @@ -5483,14 +5483,14 @@ Signed-off-by: John Crispin blo...@openwrt.org +} + +if (read) { /* Read hack */ -+#ifdef CONFIG_IFX_PCI ++#ifdef CONFIG_PCI_LANTIQ +if (pcibios_host_nr() 1) { +tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue); +} -+#endif /* CONFIG_IFX_PCI */ ++#endif /* CONFIG_PCI_LANTIQ */ +} +else { /* Write hack */ -+#ifdef CONFIG_IFX_PCI ++#ifdef CONFIG_PCI_LANTIQ +if (pcibios_host_nr() 1) { +tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue); +} -- 2.4.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] netifd: Support for configurable default packet steering
Fine with me in principle, howeverI find the name force_ps to be misleading since the option does not override or enforce anything. Maybe default_ps would be a more suitable name? Cheers, Steven On 11.05.2015 18:30, Hans Dedecker wrote: Default packet steering behavior can be configured via the parameter force_ps in the global section; the default value is true to keep backwards compatibility. Device packet steering (rps/xps) config can still be used to override the default behavior. This allows you to disable packet steering for all devices without the need to define a device config list which disables receive/transmit packet steering Signed-off-by: Hans Dedecker dedec...@gmail.com --- config.c | 6 ++ device.c | 56 +--- device.h | 3 +++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/config.c b/config.c index 48c4fbf..77ebb45 100644 --- a/config.c +++ b/config.c @@ -306,6 +306,12 @@ config_init_globals(void) const char *ula_prefix = uci_lookup_option_string( uci_ctx, globals, ula_prefix); interface_ip_set_ula_prefix(ula_prefix); + + const char *force_ps = uci_lookup_option_string( + uci_ctx, globals, force_ps); + + if (force_ps) + device_set_force_ps(strcmp(force_ps, 1) ? false : true); } static void diff --git a/device.c b/device.c index 092c2d9..afe917c 100644 --- a/device.c +++ b/device.c @@ -29,6 +29,7 @@ #include config.h static struct avl_tree devices; +static bool force_ps = true; static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_TYPE] = { .name = type, .type = BLOBMSG_TYPE_STRING }, @@ -244,15 +245,19 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s-flags |= DEV_OPT_NEIGHREACHABLETIME; } - if ((cur = tb[DEV_ATTR_RPS])) + if ((cur = tb[DEV_ATTR_RPS])) { s-rps = blobmsg_get_bool(cur); + s-flags |= DEV_OPT_RPS; + } else - s-rps = true; + s-rps = force_ps; - if ((cur = tb[DEV_ATTR_XPS])) + if ((cur = tb[DEV_ATTR_XPS])) { s-xps = blobmsg_get_bool(cur); + s-flags |= DEV_OPT_XPS; + } else - s-xps = true; + s-xps = force_ps; device_set_disabled(dev, disabled); } @@ -370,8 +375,8 @@ int device_init(struct device *dev, const struct device_type *type, const char * system_if_clear_state(dev); device_check_state(dev); - dev-settings.rps = true; - dev-settings.xps = true; + dev-settings.rps = force_ps; + dev-settings.xps = force_ps; return 0; } @@ -723,6 +728,41 @@ device_reset_old(void) } } +void +device_set_force_ps(bool state) +{ + struct device *dev; + + if (state == force_ps) + return; + + force_ps = state; + + avl_for_each_element(devices, dev, avl) { + struct device_settings *s = dev-settings; + unsigned int apply_mask = 0; + + if (!(s-flags DEV_OPT_RPS)) { + s-rps = force_ps; + apply_mask |= DEV_OPT_RPS; + } + + if (!(s-flags DEV_OPT_XPS)) { + s-xps = force_ps; + apply_mask |= DEV_OPT_XPS; + } + + if (!apply_mask) + continue; + + if (!(dev-external || (dev-present dev-active)) || + dev-config_pending) + continue; + + system_if_apply_settings(dev, s, apply_mask); + } +} + struct device * device_create(const char *name, const struct device_type *type, struct blob_attr *config) @@ -758,8 +798,10 @@ device_create(const char *name, const struct device_type *type, if (odev) device_replace(dev, odev); - if (!config_init dev-config_pending) + if (!config_init dev-config_pending) { type-config_init(dev); + dev-config_pending = false; + } return dev; } diff --git a/device.h b/device.h index 753e1fa..d80142b 100644 --- a/device.h +++ b/device.h @@ -78,6 +78,8 @@ enum { DEV_OPT_IGMPVERSION = (1 7), DEV_OPT_MLDVERSION = (1 8), DEV_OPT_NEIGHREACHABLETIME = (1 9), + DEV_OPT_RPS = (1 10), + DEV_OPT_XPS = (1 11), }; /* events broadcasted to all users of a device */ @@ -206,6 +208,7 @@ device_apply_config(struct device *dev, const struct device_type *type, void device_reset_config(void); void device_reset_old(void); +void device_set_force_ps(bool state); void device_init_virtual(struct device *dev, const struct device_type *type, const char *name); int
[OpenWrt-Devel] [PATCH 3/3] [rpcd] file: be consistent with string termination character
Signed-off-by: Luka Perkov l...@openwrt.org --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file.c b/file.c index fe1bc39..64e7c28 100644 --- a/file.c +++ b/file.c @@ -247,7 +247,7 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, } } - *(wbuf + len) = 0; + *(wbuf + len) = '\0'; blobmsg_add_string_buffer(buf); ubus_send_reply(ctx, req, buf.head); -- 2.4.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] [rpcd][v2] file: add support for base64
Hi Felix, On Mon, May 11, 2015 at 11:36:46AM +0200, Felix Fietkau wrote: On 2015-05-11 00:26, Luka Perkov wrote: Signed-off-by: Luka Perkov l...@openwrt.org --- = changes in v2: Use new libubox base64 provided API. file.c | 118 +++-- 1 file changed, 107 insertions(+), 11 deletions(-) diff --git a/file.c b/file.c index 9c1b301..c3671bb 100644 --- a/file.c +++ b/file.c @@ -182,7 +206,17 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(buf, 0); - wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + if (tb[RPC_F_RB_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RB_BASE64]); + + if (base64) + { + wbuf = blobmsg_alloc_string_buffer(buf, data, B64_ENCODE_LEN(s.st_size)); + } + else + { + wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + } How about using the 'len' variable to avoid duplicating most of the code here. Can you be more specific here please? I don't see how by using 'len' we can reduce more code here. You can also get rid of unnecessary {} lines. I have fixed this and all other comments below. New series will follow shortly. Luka @@ -196,14 +230,35 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, goto out; } + if (base64) + { + uint8_t *data = calloc(B64_ENCODE_LEN(len), sizeof(uint8_t)); + if (!data) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } You can reduce allocation/copy size if you copy wbuf to a temporary buffer and then use it as output for b64_encode. + len = b64_encode(wbuf, len, data, B64_ENCODE_LEN(len)); + if (len 0) + { + free(data); + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + + memcpy(wbuf, data, len); + free(data); + } + *(wbuf + len) = 0; blobmsg_add_string_buffer(buf); ubus_send_reply(ctx, req, buf.head); - blob_buf_free(buf); rv = UBUS_STATUS_OK; out: + blob_buf_free(buf); close(fd); return rv; } @@ -222,18 +282,54 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, if (!tb[RPC_F_RW_PATH] || !tb[RPC_F_RW_DATA]) return UBUS_STATUS_INVALID_ARGUMENT; + data = blobmsg_data(tb[RPC_F_RW_DATA]); + data_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; + if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_TRUNC | O_WRONLY, 0666)) 0) return rpc_errno_status(); - if (write(fd, blobmsg_data(tb[RPC_F_RW_DATA]), blobmsg_data_len(tb[RPC_F_RW_DATA])) 0) - return rpc_errno_status(); + if (tb[RPC_F_RW_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RW_BASE64]); + + if (base64) + { + rbuf_len = B64_DECODE_LEN(data_len); + rbuf = calloc(rbuf_len, sizeof(uint8_t)); + if (!rbuf) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + + rbuf_len = b64_decode(data, rbuf, rbuf_len); + if (rbuf_len 0) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + } + else + { + rbuf = data; + rbuf_len = data_len; + } It is safe to overwrite the data area in this function, as long as you don't overstep attribute bounds. This means you can reuse the input buffer as output buffer for b64_decode and get rid of the temporary allocation. - Felix ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] [rpcd][v2] file: add support for base64
On 2015-05-11 23:26, Luka Perkov wrote: Hi Felix, On Mon, May 11, 2015 at 11:36:46AM +0200, Felix Fietkau wrote: On 2015-05-11 00:26, Luka Perkov wrote: Signed-off-by: Luka Perkov l...@openwrt.org --- = changes in v2: Use new libubox base64 provided API. file.c | 118 +++-- 1 file changed, 107 insertions(+), 11 deletions(-) diff --git a/file.c b/file.c index 9c1b301..c3671bb 100644 --- a/file.c +++ b/file.c @@ -182,7 +206,17 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(buf, 0); - wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + if (tb[RPC_F_RB_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RB_BASE64]); + + if (base64) + { + wbuf = blobmsg_alloc_string_buffer(buf, data, B64_ENCODE_LEN(s.st_size)); + } + else + { + wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + } How about using the 'len' variable to avoid duplicating most of the code here. Can you be more specific here please? I don't see how by using 'len' we can reduce more code here. len = s.st_size + 1; if (base64) len = B64_ENCODE_LEN(s.st_size); wbuf = blobmsg_alloc_string_buffer(buf, data, len); - Felix ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] ar71xx: Add pll_1000 value for eth0
This patch adds the pll_1000 value for eth0 interface. This makes the Rocket M XW image compatible with other Ubiquiti devices with similar hardware with a Gigabit Ethernet port. --- .../ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch b/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch index 056a690..ccc752e 100644 --- a/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch +++ b/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch @@ -10,7 +10,7 @@ ATH79_MACH_UBNT_UAP_PRO,/* Ubiquiti UniFi AP Pro */ --- a/arch/mips/ath79/mach-ubnt-xm.c +++ b/arch/mips/ath79/mach-ubnt-xm.c -@@ -449,12 +449,42 @@ +@@ -449,12 +449,43 @@ ath79_register_eth(0); } @@ -38,6 +38,7 @@ + + ath79_register_mdio(0, ~BIT(4)); + ath79_eth0_data.phy_mask = BIT(4); ++ ath79_eth0_pll_data.pll_1000 = 0x0600; + ath79_register_eth(0); +} + -- 2.1.4 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] ar71xx: Add pll_1000 value for eth0 to Ubiquiti Rocket M XW
This patch adds the pll_1000 value for eth0 interface. This makes the Rocket M XW image compatible with other Ubiquiti devices with similar hardware with a Gigabit Ethernet port. Signed-off-by: Roger Pueyo Centelles roger.pu...@guifi.net --- .../ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch b/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch index 056a690..ccc752e 100644 --- a/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch +++ b/target/linux/ar71xx/patches-3.18/903-MIPS-ath79-ubnt-rocket-m-xw-support.patch @@ -10,7 +10,7 @@ ATH79_MACH_UBNT_UAP_PRO,/* Ubiquiti UniFi AP Pro */ --- a/arch/mips/ath79/mach-ubnt-xm.c +++ b/arch/mips/ath79/mach-ubnt-xm.c -@@ -449,12 +449,42 @@ +@@ -449,12 +449,43 @@ ath79_register_eth(0); } @@ -38,6 +38,7 @@ + + ath79_register_mdio(0, ~BIT(4)); + ath79_eth0_data.phy_mask = BIT(4); ++ ath79_eth0_pll_data.pll_1000 = 0x0600; + ath79_register_eth(0); +} + -- 2.1.4 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3] file: add support for base64
Signed-off-by: Luka Perkov l...@openwrt.org --- = changes in v2: Use new libubox base64 provided API. = changes in v3: * optimize base64 related code in read and write callback file.c | 90 ++ 1 file changed, 79 insertions(+), 11 deletions(-) diff --git a/file.c b/file.c index 9c1b301..d39dccb 100644 --- a/file.c +++ b/file.c @@ -29,6 +29,7 @@ #include libubox/blobmsg.h #include libubox/md5.h #include libubox/ustream.h +#include libubox/utils.h #include rpcd/plugin.h @@ -79,14 +80,27 @@ static const struct blobmsg_policy rpc_file_r_policy[__RPC_F_R_MAX] = { }; enum { + RPC_F_RB_PATH, + RPC_F_RB_BASE64, + __RPC_F_RB_MAX, +}; + +static const struct blobmsg_policy rpc_file_rb_policy[__RPC_F_RB_MAX] = { + [RPC_F_RB_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RB_BASE64] = { .name = base64, .type = BLOBMSG_TYPE_BOOL }, +}; + +enum { RPC_F_RW_PATH, RPC_F_RW_DATA, + RPC_F_RW_BASE64, __RPC_F_RW_MAX, }; static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { - [RPC_F_RW_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, - [RPC_F_RW_DATA] = { .name = data, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_DATA] = { .name = data, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_BASE64] = { .name = base64, .type = BLOBMSG_TYPE_BOOL }, }; enum { @@ -162,12 +176,22 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { - int fd, rv, len; + static struct blob_attr *tb[__RPC_F_RB_MAX]; + bool base64 = false; + int fd, rv; + ssize_t len; char *path; struct stat s; char *wbuf; - if (!rpc_check_path(msg, path, s)) + blobmsg_parse(rpc_file_rb_policy, __RPC_F_RB_MAX, tb, blob_data(msg), blob_len(msg)); + + if (!tb[RPC_F_RB_PATH]) + return rpc_errno_status(); + + path = blobmsg_data(tb[RPC_F_RB_PATH]); + + if (stat(path, s)) return rpc_errno_status(); if (s.st_size = RPC_FILE_MAX_SIZE) @@ -182,7 +206,13 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(buf, 0); - wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + if (tb[RPC_F_RB_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RB_BASE64]); + + if (base64) + wbuf = blobmsg_alloc_string_buffer(buf, data, B64_ENCODE_LEN(s.st_size)); + else + wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); if (!wbuf) { @@ -196,14 +226,33 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, goto out; } + if (base64) + { + uint8_t *data = calloc(len, sizeof(uint8_t)); + if (!data) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + memcpy(data, wbuf, len); + + len = b64_encode(data, len, wbuf, B64_ENCODE_LEN(len)); + free(data); + if (len 0) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + } + *(wbuf + len) = 0; blobmsg_add_string_buffer(buf); ubus_send_reply(ctx, req, buf.head); - blob_buf_free(buf); rv = UBUS_STATUS_OK; out: + blob_buf_free(buf); close(fd); return rv; } @@ -213,8 +262,10 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { - int fd; struct blob_attr *tb[__RPC_F_RW_MAX]; + int fd, rv = 0; + void *data = NULL; + size_t data_len = 0; blobmsg_parse(rpc_file_rw_policy, __RPC_F_RW_MAX, tb, blob_data(msg), blob_len(msg)); @@ -222,18 +273,35 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, if (!tb[RPC_F_RW_PATH] || !tb[RPC_F_RW_DATA]) return UBUS_STATUS_INVALID_ARGUMENT; + data = blobmsg_data(tb[RPC_F_RW_DATA]); + data_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; + if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_TRUNC | O_WRONLY, 0666)) 0) return rpc_errno_status(); - if (write(fd, blobmsg_data(tb[RPC_F_RW_DATA]), blobmsg_data_len(tb[RPC_F_RW_DATA])) 0) - return rpc_errno_status(); + if (tb[RPC_F_RW_BASE64] blobmsg_get_bool(tb[RPC_F_RW_BASE64])) + { + data_len = b64_decode(data, data, data_len); + if
[OpenWrt-Devel] [PATCH 2/3] file: add support for setting mode when writing files
Signed-off-by: Luka Perkov l...@openwrt.org --- = changes in v2: Return umask() to previous value after temporary changing it. file.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/file.c b/file.c index d39dccb..fe1bc39 100644 --- a/file.c +++ b/file.c @@ -93,6 +93,7 @@ static const struct blobmsg_policy rpc_file_rb_policy[__RPC_F_RB_MAX] = { enum { RPC_F_RW_PATH, RPC_F_RW_DATA, + RPC_F_RW_MODE, RPC_F_RW_BASE64, __RPC_F_RW_MAX, }; @@ -100,6 +101,7 @@ enum { static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { [RPC_F_RW_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, [RPC_F_RW_DATA] = { .name = data, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_MODE] = { .name = mode, .type = BLOBMSG_TYPE_INT32 }, [RPC_F_RW_BASE64] = { .name = base64, .type = BLOBMSG_TYPE_BOOL }, }; @@ -263,6 +265,7 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, struct blob_attr *msg) { struct blob_attr *tb[__RPC_F_RW_MAX]; + mode_t prev_mode, mode = 0666; int fd, rv = 0; void *data = NULL; size_t data_len = 0; @@ -276,7 +279,13 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, data = blobmsg_data(tb[RPC_F_RW_DATA]); data_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; - if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_TRUNC | O_WRONLY, 0666)) 0) + if (tb[RPC_F_RW_MODE]) + mode = blobmsg_get_u32(tb[RPC_F_RW_MODE]); + + prev_mode = umask(0); + fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | O_TRUNC, mode); + umask(prev_mode); + if (fd 0) return rpc_errno_status(); if (tb[RPC_F_RW_BASE64] blobmsg_get_bool(tb[RPC_F_RW_BASE64])) -- 2.4.0 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH 1/3][rpcd][v4] file: add support for base64
Signed-off-by: Luka Perkov l...@openwrt.org --- = changes in v2: Use new libubox base64 provided API. = changes in v3: * optimize base64 related code in read and write callback = changes in v4: * tweak if block in file read function file.c | 90 ++ 1 file changed, 79 insertions(+), 11 deletions(-) diff --git a/file.c b/file.c index 9c1b301..02fb72e 100644 --- a/file.c +++ b/file.c @@ -29,6 +29,7 @@ #include libubox/blobmsg.h #include libubox/md5.h #include libubox/ustream.h +#include libubox/utils.h #include rpcd/plugin.h @@ -79,14 +80,27 @@ static const struct blobmsg_policy rpc_file_r_policy[__RPC_F_R_MAX] = { }; enum { + RPC_F_RB_PATH, + RPC_F_RB_BASE64, + __RPC_F_RB_MAX, +}; + +static const struct blobmsg_policy rpc_file_rb_policy[__RPC_F_RB_MAX] = { + [RPC_F_RB_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RB_BASE64] = { .name = base64, .type = BLOBMSG_TYPE_BOOL }, +}; + +enum { RPC_F_RW_PATH, RPC_F_RW_DATA, + RPC_F_RW_BASE64, __RPC_F_RW_MAX, }; static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = { - [RPC_F_RW_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, - [RPC_F_RW_DATA] = { .name = data, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_PATH] = { .name = path, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_DATA] = { .name = data, .type = BLOBMSG_TYPE_STRING }, + [RPC_F_RW_BASE64] = { .name = base64, .type = BLOBMSG_TYPE_BOOL }, }; enum { @@ -162,12 +176,22 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { - int fd, rv, len; + static struct blob_attr *tb[__RPC_F_RB_MAX]; + bool base64 = false; + int fd, rv; + ssize_t len; char *path; struct stat s; char *wbuf; - if (!rpc_check_path(msg, path, s)) + blobmsg_parse(rpc_file_rb_policy, __RPC_F_RB_MAX, tb, blob_data(msg), blob_len(msg)); + + if (!tb[RPC_F_RB_PATH]) + return rpc_errno_status(); + + path = blobmsg_data(tb[RPC_F_RB_PATH]); + + if (stat(path, s)) return rpc_errno_status(); if (s.st_size = RPC_FILE_MAX_SIZE) @@ -182,7 +206,13 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(buf, 0); - wbuf = blobmsg_alloc_string_buffer(buf, data, s.st_size + 1); + if (tb[RPC_F_RB_BASE64]) + base64 = blobmsg_get_bool(tb[RPC_F_RB_BASE64]); + + len = s.st_size + 1; + if (base64) + len = B64_ENCODE_LEN(s.st_size); + wbuf = blobmsg_alloc_string_buffer(buf, data, len); if (!wbuf) { @@ -196,14 +226,33 @@ rpc_file_read(struct ubus_context *ctx, struct ubus_object *obj, goto out; } + if (base64) + { + uint8_t *data = calloc(len, sizeof(uint8_t)); + if (!data) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + memcpy(data, wbuf, len); + + len = b64_encode(data, len, wbuf, B64_ENCODE_LEN(len)); + free(data); + if (len 0) + { + rv = UBUS_STATUS_UNKNOWN_ERROR; + goto out; + } + } + *(wbuf + len) = 0; blobmsg_add_string_buffer(buf); ubus_send_reply(ctx, req, buf.head); - blob_buf_free(buf); rv = UBUS_STATUS_OK; out: + blob_buf_free(buf); close(fd); return rv; } @@ -213,8 +262,10 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) { - int fd; struct blob_attr *tb[__RPC_F_RW_MAX]; + int fd, rv = 0; + void *data = NULL; + size_t data_len = 0; blobmsg_parse(rpc_file_rw_policy, __RPC_F_RW_MAX, tb, blob_data(msg), blob_len(msg)); @@ -222,18 +273,35 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object *obj, if (!tb[RPC_F_RW_PATH] || !tb[RPC_F_RW_DATA]) return UBUS_STATUS_INVALID_ARGUMENT; + data = blobmsg_data(tb[RPC_F_RW_DATA]); + data_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1; + if ((fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_TRUNC | O_WRONLY, 0666)) 0) return rpc_errno_status(); - if (write(fd, blobmsg_data(tb[RPC_F_RW_DATA]), blobmsg_data_len(tb[RPC_F_RW_DATA])) 0) - return rpc_errno_status(); + if (tb[RPC_F_RW_BASE64] blobmsg_get_bool(tb[RPC_F_RW_BASE64])) + { + data_len = b64_decode(data, data, data_len); +
[OpenWrt-Devel] [PATCH] ar71xx: Add support for the Meraki MR12 MR16
This patch is to add support for the Meraki MR12 and MR16 Access Points. Currently everything is working, minus the 2nd NIC interface on the MR12 which is built into the SoC. Signed-off-by: Chris R Blake chrisrblake93 at gmail.com -- diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index d702d45..785888d 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -109,6 +109,12 @@ get_status_led() { mc-mac1200r) status_led=mercury:green:system ;; + mr12) + status_led=mr12:green:power + ;; + mr16) + status_led=mr16:green:power + ;; mr600) status_led=mr600:orange:power ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds index 16064de..41b 100644 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds @@ -178,6 +178,22 @@ mc-mac1200r) ucidef_set_led_wlan wlan5g WLAN5G mercury:green:wlan5g phy0tpt ;; +mr12) + ucidef_set_led_netdev wan WAN mr12:green:wan eth0 + ucidef_set_led_wlan wlan1 WLAN1 mr12:green:wifi1 phy0assoc + ucidef_set_led_wlan wlan2 WLAN2 mr12:green:wifi2 phy0assoc + ucidef_set_led_wlan wlan3 WLAN3 mr12:green:wifi3 phy0assoc + ucidef_set_led_wlan wlan4 WLAN4 mr12:green:wifi4 phy0tpt + ;; + +mr16) + ucidef_set_led_netdev wan WAN mr16:green:wan eth0 + ucidef_set_led_wlan wlan1 WLAN1 mr16:green:wifi1 phy0assoc + ucidef_set_led_wlan wlan2 WLAN2 mr16:green:wifi2 phy0assoc + ucidef_set_led_wlan wlan3 WLAN3 mr16:green:wifi3 phy0assoc + ucidef_set_led_wlan wlan4 WLAN4 mr16:green:wifi4 phy0tpt + ;; + mr600) ucidef_set_led_wlan wlan58 WLAN58 mr600:green:wlan58 phy0tpt ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration b/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration index d9aa519..aa0e1b4 100644 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration @@ -61,6 +61,8 @@ dir-615-c1|\ dir-615-e1|\ dir-615-e4|\ ja76pf|\ +mr-12|\ +mr-16|\ rb-750|\ rb-751|\ tew-632brp|\ diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 645c5d9..d5dd561 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -471,6 +471,12 @@ ar71xx_board_detect() { *MAC1200R) name=mc-mac1200r ;; + *MR12) + name=mr12 + ;; + *MR16) + name=mr16 + ;; *MR600v2) name=mr600v2 ;; diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index b3c61ef..82b5bfa 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -184,6 +184,8 @@ platform_check_image() { db120 | \ f9k1115v2 |\ hornet-ub | \ + mr12 | \ + mr16 | \ wpj558 | \ zcn-1523h-2 | \ zcn-1523h-5) diff --git a/target/linux/ar71xx/config-3.18 b/target/linux/ar71xx/config-3.18 index 36b8bb6..543b77e 100644 --- a/target/linux/ar71xx/config-3.18 +++ b/target/linux/ar71xx/config-3.18 @@ -68,6 +68,8 @@ CONFIG_ATH79_MACH_HORNET_UB=y CONFIG_ATH79_MACH_JA76PF=y CONFIG_ATH79_MACH_JWAP003=y CONFIG_ATH79_MACH_MC_MAC1200R=y +CONFIG_ATH79_MACH_MR16=y +CONFIG_ATH79_MACH_MR12=y CONFIG_ATH79_MACH_MR600=y CONFIG_ATH79_MACH_MR900=y CONFIG_ATH79_MACH_MYNET_N600=y diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-mr12.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-mr12.c new file mode 100644 index 000..12c9a1c --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-mr12.c @@ -0,0 +1,115 @@ +/* + * Cisco Meraki MR12 board support + * + * Copyright (C) 2014-2015 Chris Blake chrisrblak...@gmail.com + * + * Based on Atheros AP96 board support configuration + * + * Copyright (C) 2009 Marco Porsch + * Copyright (C) 2009-2012 Gabor Juhos juh...@openwrt.org + * Copyright (C) 2010 Atheros Communications + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include linux/platform_device.h +#include linux/delay.h + +#include asm/mach-ath79/ath79.h + +#include dev-ap9x-pci.h +#include dev-eth.h +#include dev-gpio-buttons.h +#include dev-leds-gpio.h +#include dev-m25p80.h +#include machtypes.h
[OpenWrt-Devel] [PATCH 1/1] Fix bridge-utils file offset handling
Make sure brctl build uses appropriate defines (_FILE_OFFSET_BITS) that match uClibc settings. Without this patch running brctl leads to 'unresolved alphasort symbol' message. Signed-off-by: Nikolay Martynov mar.ko...@gmail.com --- net/bridge-utils/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bridge-utils/Makefile b/net/bridge-utils/Makefile index ad95b87..10e44c5 100644 --- a/net/bridge-utils/Makefile +++ b/net/bridge-utils/Makefile @@ -30,6 +30,8 @@ define Package/bridge/description form a larger network. endef +TARGET_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE + CONFIGURE_ARGS += \ --with-linux-headers=$(LINUX_DIR) \ -- 1.9.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] netifd: Support for configurable default packet steering
Default packet steering behavior can be configured via the parameter force_ps in the global section; the default value is true to keep backwards compatibility. Device packet steering (rps/xps) config can still be used to override the default behavior. This allows you to disable packet steering for all devices without the need to define a device config list which disables receive/transmit packet steering Signed-off-by: Hans Dedecker dedec...@gmail.com --- config.c | 6 ++ device.c | 56 +--- device.h | 3 +++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/config.c b/config.c index 48c4fbf..77ebb45 100644 --- a/config.c +++ b/config.c @@ -306,6 +306,12 @@ config_init_globals(void) const char *ula_prefix = uci_lookup_option_string( uci_ctx, globals, ula_prefix); interface_ip_set_ula_prefix(ula_prefix); + + const char *force_ps = uci_lookup_option_string( + uci_ctx, globals, force_ps); + + if (force_ps) + device_set_force_ps(strcmp(force_ps, 1) ? false : true); } static void diff --git a/device.c b/device.c index 092c2d9..afe917c 100644 --- a/device.c +++ b/device.c @@ -29,6 +29,7 @@ #include config.h static struct avl_tree devices; +static bool force_ps = true; static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_TYPE] = { .name = type, .type = BLOBMSG_TYPE_STRING }, @@ -244,15 +245,19 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s-flags |= DEV_OPT_NEIGHREACHABLETIME; } - if ((cur = tb[DEV_ATTR_RPS])) + if ((cur = tb[DEV_ATTR_RPS])) { s-rps = blobmsg_get_bool(cur); + s-flags |= DEV_OPT_RPS; + } else - s-rps = true; + s-rps = force_ps; - if ((cur = tb[DEV_ATTR_XPS])) + if ((cur = tb[DEV_ATTR_XPS])) { s-xps = blobmsg_get_bool(cur); + s-flags |= DEV_OPT_XPS; + } else - s-xps = true; + s-xps = force_ps; device_set_disabled(dev, disabled); } @@ -370,8 +375,8 @@ int device_init(struct device *dev, const struct device_type *type, const char * system_if_clear_state(dev); device_check_state(dev); - dev-settings.rps = true; - dev-settings.xps = true; + dev-settings.rps = force_ps; + dev-settings.xps = force_ps; return 0; } @@ -723,6 +728,41 @@ device_reset_old(void) } } +void +device_set_force_ps(bool state) +{ + struct device *dev; + + if (state == force_ps) + return; + + force_ps = state; + + avl_for_each_element(devices, dev, avl) { + struct device_settings *s = dev-settings; + unsigned int apply_mask = 0; + + if (!(s-flags DEV_OPT_RPS)) { + s-rps = force_ps; + apply_mask |= DEV_OPT_RPS; + } + + if (!(s-flags DEV_OPT_XPS)) { + s-xps = force_ps; + apply_mask |= DEV_OPT_XPS; + } + + if (!apply_mask) + continue; + + if (!(dev-external || (dev-present dev-active)) || + dev-config_pending) + continue; + + system_if_apply_settings(dev, s, apply_mask); + } +} + struct device * device_create(const char *name, const struct device_type *type, struct blob_attr *config) @@ -758,8 +798,10 @@ device_create(const char *name, const struct device_type *type, if (odev) device_replace(dev, odev); - if (!config_init dev-config_pending) + if (!config_init dev-config_pending) { type-config_init(dev); + dev-config_pending = false; + } return dev; } diff --git a/device.h b/device.h index 753e1fa..d80142b 100644 --- a/device.h +++ b/device.h @@ -78,6 +78,8 @@ enum { DEV_OPT_IGMPVERSION = (1 7), DEV_OPT_MLDVERSION = (1 8), DEV_OPT_NEIGHREACHABLETIME = (1 9), + DEV_OPT_RPS = (1 10), + DEV_OPT_XPS = (1 11), }; /* events broadcasted to all users of a device */ @@ -206,6 +208,7 @@ device_apply_config(struct device *dev, const struct device_type *type, void device_reset_config(void); void device_reset_old(void); +void device_set_force_ps(bool state); void device_init_virtual(struct device *dev, const struct device_type *type, const char *name); int device_init(struct device *iface, const struct device_type *type, const char *ifname); -- 1.9.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org
Re: [OpenWrt-Devel] [PATCH] ar71xx: add support for the UniFi AP Outdoor Plus
On 03/21/2015 10:16 AM, Stefan Rompf wrote: Hi Sergey, You should be a wizard to reveal hw protocol without touching hw :) I cannot say 'Mischief managed!' by now, but it's slowly making progress ;-) Unlikely that iwconfig changes something directly, I would bet on the driver. Indeed. So far -The RF filter is controlled by the GPIO pins on the AR928x wifi chip via some kind of serial protocol. -The functions responsible for the filter are ath_hal_hsr_init(), called once on initialisation, ath_hal_hsr_disable() and ath_hal_hsr_enable() on channel change. There is an ath_hal_hsr_get_lock_status() that does not seem to be used. -There seems to be no filter tuning after it has been setup on channel change. Reverse engineering this unreadable MIPS assembly mess will take some time... anyone willing to help? Does it make sense to open a ticket to track the issue or is this mailing list ok? Stefan Any news here? I know a lot of people who are eager to run OpenWrt on their UAP Outdoor+ ... If you don't have time to do further work on this, I'd be glad to continue where you left off. Have you found out anything substantial that might help? Regards, Matthias signature.asc Description: OpenPGP digital signature ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel