projects
/
project
/
odhcpd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix last commit
[project/odhcpd.git]
/
src
/
config.c
diff --git
a/src/config.c
b/src/config.c
index
ebc6642
..
e31740b
100644
(file)
--- a/
src/config.c
+++ b/
src/config.c
@@
-260,7
+260,10
@@
int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite
blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blob_data(b), blob_len(b));
if (tb[IFACE_ATTR_INTERFACE])
blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blob_data(b), blob_len(b));
if (tb[IFACE_ATTR_INTERFACE])
- name = blobmsg_data(tb[IFACE_ATTR_INTERFACE]);
+ name = blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]);
+
+ if (!name)
+ return -1;
struct interface *iface = get_interface(name);
if (!iface) {
struct interface *iface = get_interface(name);
if (!iface) {
@@
-281,6
+284,9
@@
int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite
else if ((c = tb[IFACE_ATTR_NETWORKID]))
ifname = blobmsg_get_string(c);
else if ((c = tb[IFACE_ATTR_NETWORKID]))
ifname = blobmsg_get_string(c);
+ if (!ifname)
+ return -1;
+
strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
iface->inuse = true;
strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
iface->inuse = true;
@@
-331,7
+337,7
@@
int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite
if ((c = tb[IFACE_ATTR_UPSTREAM])) {
struct blob_attr *cur;
if ((c = tb[IFACE_ATTR_UPSTREAM])) {
struct blob_attr *cur;
-
int
rem;
+
unsigned
rem;
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
@@
-344,25
+350,38
@@
int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite
}
}
}
}
- if ((c = tb[IFACE_ATTR_RA]))
- if ((iface->ra = parse_mode(blobmsg_get_string(c))) < 0)
+ int mode;
+ if ((c = tb[IFACE_ATTR_RA])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->ra = mode;
+ else
goto err;
goto err;
+ }
- if ((c = tb[IFACE_ATTR_DHCPV4]))
- if ((iface->dhcpv4 = parse_mode(blobmsg_get_string(c))) < 0)
+ if ((c = tb[IFACE_ATTR_DHCPV4])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->dhcpv4 = mode;
+ else
goto err;
goto err;
+ }
- if ((c = tb[IFACE_ATTR_DHCPV6]))
- if ((iface->dhcpv6 = parse_mode(blobmsg_get_string(c))) < 0)
+ if ((c = tb[IFACE_ATTR_DHCPV6])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->dhcpv6 = mode;
+ else
goto err;
goto err;
+ }
- if ((c = tb[IFACE_ATTR_NDP]))
- if ((iface->ndp = parse_mode(blobmsg_get_string(c))) < 0)
+ if ((c = tb[IFACE_ATTR_NDP])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->ndp = mode;
+ else
goto err;
goto err;
+ }
if ((c = tb[IFACE_ATTR_DNS])) {
struct blob_attr *cur;
if ((c = tb[IFACE_ATTR_DNS])) {
struct blob_attr *cur;
-
int
rem;
+
unsigned
rem;
iface->always_rewrite_dns = true;
blobmsg_for_each_attr(cur, c, rem) {
iface->always_rewrite_dns = true;
blobmsg_for_each_attr(cur, c, rem) {
@@
-387,7
+406,7
@@
int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite
if ((c = tb[IFACE_ATTR_DOMAIN])) {
struct blob_attr *cur;
if ((c = tb[IFACE_ATTR_DOMAIN])) {
struct blob_attr *cur;
-
int
rem;
+
unsigned
rem;
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
@@
-437,7
+456,7
@@
int config_parse_interface(struct blob_attr *b, const char *name, bool overwrite
if ((c = tb[IFACE_ATTR_NDPROXY_STATIC])) {
struct blob_attr *cur;
if ((c = tb[IFACE_ATTR_NDPROXY_STATIC])) {
struct blob_attr *cur;
-
int
rem;
+
unsigned
rem;
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
@@
-466,7
+485,7
@@
static int set_interface(struct uci_section *s)
}
}
-static volatile
bool
do_reload = false;
+static volatile
int
do_reload = false;
static void set_stop(int signal)
{
uloop_end();
static void set_stop(int signal)
{
uloop_end();
@@
-480,8
+499,12
@@
void odhcpd_run(void)
signal(SIGHUP, set_stop);
signal(SIGINT, set_stop);
signal(SIGHUP, set_stop);
signal(SIGINT, set_stop);
+#ifdef WITH_UBUS
+ init_ubus();
+#endif
+
do {
do {
- do_reload = false;
+ do_reload =
uloop_cancelled =
false;
struct lease *l;
list_for_each_entry(l, &leases, head) {
struct lease *l;
list_for_each_entry(l, &leases, head) {
@@
-513,7
+536,7
@@
void odhcpd_run(void)
#endif
// Evaluate hybrid mode for master
#endif
// Evaluate hybrid mode for master
- struct interface *master = NULL, *i;
+ struct interface *master = NULL, *i
, *n
;
list_for_each_entry(i, &interfaces, head) {
if (!i->master)
continue;
list_for_each_entry(i, &interfaces, head) {
if (!i->master)
continue;
@@
-538,8
+561,8
@@
void odhcpd_run(void)
}
}
- list_for_each_entry
(i
, &interfaces, head) {
- if (i->inuse
&& !i->ignore
) {
+ list_for_each_entry
_safe(i, n
, &interfaces, head) {
+ if (i->inuse) {
// Resolve hybrid mode
if (i->dhcpv6 == RELAYD_HYBRID)
i->dhcpv6 = (master && master->dhcpv6 == RELAYD_RELAY) ?
// Resolve hybrid mode
if (i->dhcpv6 == RELAYD_HYBRID)
i->dhcpv6 = (master && master->dhcpv6 == RELAYD_RELAY) ?