[OpenWrt-Devel] Set enable_vlan4k by default?

2020-01-13 Thread Juliusz Chroboczek
I just spent a good few minutes trying to find out why my VLAN setup was
being ignored.  It turned out that I needed to say:

option enable_vlan4k 1

Is there any good reason why this is not the default setting?

(19.07.0, ath79, switch is rtl8366s.)

-- Juliusz

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Slow DNSMasq with > 100, 000 entries in additional addresses file

2016-12-29 Thread Juliusz Chroboczek
> I also fiddled a bit with bloom filters, which strike me as appropo.

Bloom filters trade accuracy for space -- they're arbitrarily smaller than
hash tables, but at the cost of causing more false positives.  Since your
tests indicate that perfect hash tables are small enough, a Bloom filter
would probably not be useful here.

If I had a few days to spare on the issue, I'd rework the data structures
in dnsmasq to deal with that case.  While I haven't looked at the dnsmasq
code, 100 000 entries is not a lot, if dnsmasq cannot deal with that, it's
probably using very naive data structures, it should be easy enough to use
something better.

(I'd use a B-tree, by the way, which is a pain to implement but should
give much better performance than open hashing.  If you're too lazy to
implement B-trees, then use pre-randomized binary search trees, they
should be just as good as AVL or RB-trees and trivial to implement.)

-- Juliusz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Interesting issue with hnetd-nossl

2016-06-24 Thread Juliusz Chroboczek
> Installing the "ip" package fixes the issue -- perhaps there is a bug in
> the busybox ip command that gets triggered by hnetd-nossl, perhaps
> something else.

This is now https://dev.openwrt.org/ticket/22671

-- Juliusz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] MPTCP

2016-06-21 Thread Juliusz Chroboczek
> I'm now having a highly experimental version of MPTCP (as a package) for
> 15.05, (and one that builds on my old dirty trunk with the old
> patches-4.1 still i place)

Just to make sure people don't get confused -- MP-TCP doesn't need router
support, and OpenWRT/LEDE is quite able to route MP-TCP traffic flowing
through it out of the box.

MP-TCP on the router is only needed for traffic that terminates at the
router.  It's a good idea e.g. if you're running a web server on your
router.

-- Juliusz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Interesting issue with hnetd-nossl

2016-06-10 Thread Juliusz Chroboczek
Dear Markus, dear Steven,

[openwrt-devel in CC]

We've just spent the afternoon debugging an interesting issue.

After installing hnetd-nossl, the router no longer answers to link-local
IPv6 addresses -- it still has the fe80:: addresses assigned, it receives
neighbour solicitations, but doesn't send neighbour announcements.
Rebooting doesn't fix the issue.

The routing table (ip -6 route show) no longer contains entries for fe80::/64,
but I don't know if this is an artifact or a real symptom.

Installing the "ip" package fixes the issue -- perhaps there is a bug in
the busybox ip command that gets triggered by hnetd-nossl, perhaps
something else.

A simple workaround would be to have hnetd-nossl depend on ip, but it
would be good to understand the underlying issue.  But it's late now.

-- Juliusz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] BGP-LS support in OPENWRT

2016-01-25 Thread Juliusz Chroboczek
> It's been great to see how some new protocols like HomeNet[1] get
> supported in latest Trunk of OpenWRT and I was wondering if there was any
> plan or possibility to do the same for BGP-LS and PCEP?

Iben,

The routing package feed is part of the default configuration of OpenWRT.
Both Bird and Quagga are packaged, so OpenWRT will gain support for BGP-LS
and PCEP as soon as it gets implemented in either Bird or Quagga.
Implementing a new protocol in Bird is easy, and the community is friendly.

If these protocols are implemented in separate daemons (as is the case of
Babel, which is used by Homenet), it should be easy enough to package the
additional daemons for OpenWRT.

-- Juliusz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] watchping

2015-07-03 Thread Juliusz Chroboczek
Hi Bruno,

 Sometimes it's necessary to re-configure an OpenWRT system based on the
 fact wether Internet connectivity is available on a certain interface.
[...]
 One example where this is useful is: When Internet is available, we
 configure BATMAN to act as a gateway 'server', if not as a gateway
 'client'.

I think that a solution that relies on distribution scripts is inherently
brittle.  The routing daemon should be able to detect the current
configuration, in a distribution-independent manner, and automatically
adapt to the current situation.  This is what happens with babeld -- it is
able to automatically redistribute a kernel route (typically the default
route, but not necessarily) into the routing protocol.

I know of three ways of automatically obtaining a default route, in
descending order of preference:

  - if the other end of the Internet connection speaks RIP, RIPng or OSPF,
we run Quagga on the gateway and redistribute into Babel;

  - if DHCPv4 is reliable (it usually is), then we simply redistribute the
DHCP-provided route into the routing protocol;

  - if DHCPv4 is unreliable, we use the babel-pinger utility which
pings a remote host and installs a route depending on its availability.

Additionally, there is some very promising but still experimental work to
provide a fully general and highly integrated solution in the hnetd-full
package.

-- Juliusz
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/2] Provide meaningful error messages when fork fails.

2015-06-25 Thread Juliusz Chroboczek
---
 inittab.c | 6 +++---
 rcS.c | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/inittab.c b/inittab.c
index eb402f8..2767e17 100644
--- a/inittab.c
+++ b/inittab.c
@@ -116,13 +116,13 @@ static void fork_worker(struct init_action *a)
execvp(a-argv[0], a-argv);
ERROR(Failed to execute %s\n, a-argv[0]);
exit(-1);
-   }
-
-   if (a-proc.pid  0) {
+   } if (a-proc.pid  0) {
DEBUG(4, Launched new %s action, pid=%d\n,
a-handler-name,
(int) a-proc.pid);
uloop_process_add(a-proc);
+   } else {
+   ERROR(Failed to create process for %s\n, a-argv[0]);
}
 }
 
diff --git a/rcS.c b/rcS.c
index 8c72c19..1e8b676 100644
--- a/rcS.c
+++ b/rcS.c
@@ -75,8 +75,10 @@ static void q_initd_run(struct runqueue *q, struct 
runqueue_task *t)
}
 
pid = fork();
-   if (pid  0)
+   if (pid  0) {
+   ERROR(Failed to create process.\n);
return;
+   }
 
if (pid) {
close(pipefd[1]);
-- 
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] Deal with allocation errors in a few missing places.

2015-06-25 Thread Juliusz Chroboczek
Since libubox is used by procd, it should deal gracefully with allocation
failures.
---
 blobmsg_json.c |  2 ++
 json_script.c  |  3 +++
 kvlist.c   |  4 
 ustream.c  | 16 +---
 utils.c|  3 +++
 5 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/blobmsg_json.c b/blobmsg_json.c
index ffde23d..1f2b4bc 100644
--- a/blobmsg_json.c
+++ b/blobmsg_json.c
@@ -297,6 +297,8 @@ char *blobmsg_format_json_with_cb(struct blob_attr *attr, 
bool list, blobmsg_jso
 
s.len = blob_len(attr);
s.buf = malloc(s.len);
+if (!s.buf)
+return NULL;
s.pos = 0;
s.custom_format = cb;
s.priv = priv;
diff --git a/json_script.c b/json_script.c
index 73c2502..8fe58b0 100644
--- a/json_script.c
+++ b/json_script.c
@@ -44,6 +44,9 @@ json_script_file_from_blobmsg(const char *name, void *data, 
int len)
name_len = strlen(name) + 1;
 
f = calloc_a(sizeof(*f) + len, new_name, name_len);
+if (!f)
+   return NULL;
+
memcpy(f-data, data, len);
if (name)
f-avl.key = strcpy(new_name, name);
diff --git a/kvlist.c b/kvlist.c
index e0a8acb..4097109 100644
--- a/kvlist.c
+++ b/kvlist.c
@@ -81,6 +81,10 @@ void kvlist_set(struct kvlist *kv, const char *name, const 
void *data)
 
node = calloc_a(sizeof(struct kvlist_node) + len,
name_buf, strlen(name) + 1);
+if (!node)
+/* XXX */
+return;
+
memcpy(node-data, data, len);
 
node-avl.key = strcpy(name_buf, name);
diff --git a/ustream.c b/ustream.c
index e7ee9f0..e051b68 100644
--- a/ustream.c
+++ b/ustream.c
@@ -65,6 +65,9 @@ static int ustream_alloc_default(struct ustream *s, struct 
ustream_buf_list *l)
return -1;
 
buf = malloc(sizeof(*buf) + l-buffer_len + s-string_data);
+   if (!buf)
+   return -1;
+
ustream_init_buf(buf, l-buffer_len);
ustream_add_buf(l, buf);
 
@@ -490,6 +493,8 @@ int ustream_vprintf(struct ustream *s, const char *format, 
va_list arg)
return ustream_write_buffered(s, buf, maxlen, wr);
} else {
buf = malloc(maxlen + 1);
+   if (!buf)
+   return 0;
wr = vsnprintf(buf, maxlen + 1, format, arg);
wr = ustream_write(s, buf, wr, false);
free(buf);
@@ -507,20 +512,25 @@ int ustream_vprintf(struct ustream *s, const char 
*format, va_list arg)
maxlen = vsnprintf(buf, buflen, format, arg2);
va_end(arg2);
 
+   buf = malloc(maxlen + 1);
+   if (!buf)
+   return 0;
+
wr = maxlen;
if (wr = buflen)
wr = buflen - 1;
 
l-data_tail-tail += wr;
l-data_bytes += wr;
-   if (maxlen  buflen)
+   if (maxlen  buflen) {
+   free(buf);
return wr;
+   }
 
-   buf = malloc(maxlen + 1);
maxlen = vsnprintf(buf, maxlen + 1, format, arg);
wr = ustream_write_buffered(s, buf + wr, maxlen - wr, wr);
-   free(buf);
 
+   free(buf);
return wr;
 }
 
diff --git a/utils.c b/utils.c
index 8fd19f4..e9a1b69 100644
--- a/utils.c
+++ b/utils.c
@@ -43,6 +43,9 @@ void *__calloc_a(size_t len, ...)
va_end(ap1);
 
ptr = calloc(1, alloc_len);
+if(ptr == NULL)
+   return NULL;
+
alloc_len = 0;
foreach_arg(ap, cur_addr, cur_len, ret, len) {
*cur_addr = ptr[alloc_len];
-- 
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] Deal gracefully with allocation failures in a few omitted places.

2015-06-25 Thread Juliusz Chroboczek
---
 libubus.c   | 3 +++
 ubusd_acl.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/libubus.c b/libubus.c
index ccaa069..9aae613 100644
--- a/libubus.c
+++ b/libubus.c
@@ -77,6 +77,9 @@ ubus_queue_msg(struct ubus_context *ctx, struct 
ubus_msghdr_buf *buf)
void *data;
 
pending = calloc_a(sizeof(*pending), data, blob_raw_len(buf-data));
+if (!pending)
+   /* XXX */
+   return;
 
pending-hdr.data = data;
memcpy(pending-hdr.hdr, buf-hdr, sizeof(buf-hdr));
diff --git a/ubusd_acl.c b/ubusd_acl.c
index 3c16114..5ed7b99 100644
--- a/ubusd_acl.c
+++ b/ubusd_acl.c
@@ -207,6 +207,8 @@ ubusd_acl_alloc_obj(struct ubusd_acl_file *file, const char 
*obj)
char *k;
 
o = calloc_a(1, sizeof(*o), k, strlen(obj) + 1);
+if (!o)
+   return NULL;
o-user = file-user;
o-group = file-group;
o-avl.key = k;
-- 
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 2/2] Attempt to deal gracefully with allocation failures.

2015-06-25 Thread Juliusz Chroboczek
These should probably not happen in practice, but having an explicit
error message may make debugging out-of-memory situations easier.
---
 rcS.c| 9 +
 system.c | 5 +
 2 files changed, 14 insertions(+)

diff --git a/rcS.c b/rcS.c
index 1e8b676..d9bd4f4 100644
--- a/rcS.c
+++ b/rcS.c
@@ -117,6 +117,10 @@ static void add_initd(struct runqueue *q, char *file, char 
*param)
char *p, *f;
 
s = calloc_a(sizeof(*s), f, strlen(file) + 1, p, strlen(param) + 1);
+   if (!s) {
+   ERROR(Out of memory in %s.\n, file);
+   return;
+   }
s-proc.task.type = initd_type;
s-proc.task.complete = q_initd_complete;
if (!strcmp(param, stop) || !strcmp(param, shutdown))
@@ -134,6 +138,11 @@ static int _rc(struct runqueue *q, char *path, const char 
*file, char *pattern,
glob_t gl;
int j;
 
+   if (!dir) {
+   ERROR(Out of memory in %s.\n, file);
+   return -1;
+   }
+
DEBUG(2, running %s/%s%s %s\n, path, file, pattern, param);
sprintf(dir, %s/%s%s, path, file, pattern);
if (glob(dir, GLOB_NOESCAPE | GLOB_MARK, NULL, gl)) {
diff --git a/system.c b/system.c
index 77111f9..82c672e 100644
--- a/system.c
+++ b/system.c
@@ -144,6 +144,11 @@ static int system_board(struct ubus_context *ctx, struct 
ubus_object *obj,
continue;
 
dest = blobmsg_alloc_string_buffer(b, key, 
strlen(val));
+   if (!dest) {
+   ERROR(Failed to allocate blob.\n);
+   continue;
+   }
+
while (val  (ch = *(val++)) != 0) {
switch (ch) {
case '\'':
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel