projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove commented out TODO items
[project/netifd.git]
/
interface.c
diff --git
a/interface.c
b/interface.c
index
4a42ad9
..
352c734
100644
(file)
--- a/
interface.c
+++ b/
interface.c
@@
-79,7
+79,7
@@
void interface_add_error(struct interface *iface, const char *subsystem,
struct interface_error *error;
int i, len = 0;
int *datalen = NULL;
struct interface_error *error;
int i, len = 0;
int *datalen = NULL;
- char *dest;
+ char *dest
, *d_subsys, *d_code
;
if (n_data) {
len = n_data * sizeof(char *);
if (n_data) {
len = n_data * sizeof(char *);
@@
-90,13
+90,13
@@
void interface_add_error(struct interface *iface, const char *subsystem,
}
}
}
}
- error = calloc(1, sizeof(*error) + sizeof(char *) + len);
+ error = calloc_a(sizeof(*error) + sizeof(char *) + len,
+ &d_subsys, subsystem ? strlen(subsystem) + 1 : 0,
+ &d_code, code ? strlen(code) + 1 : 0);
if (!error)
return;
list_add_tail(&error->list, &iface->errors);
if (!error)
return;
list_add_tail(&error->list, &iface->errors);
- error->subsystem = subsystem;
- error->code = code;
dest = (char *) &error->data[n_data + 1];
for (i = 0; i < n_data; i++) {
dest = (char *) &error->data[n_data + 1];
for (i = 0; i < n_data; i++) {
@@
-104,7
+104,13
@@
void interface_add_error(struct interface *iface, const char *subsystem,
memcpy(dest, data[i], datalen[i]);
dest += datalen[i];
}
memcpy(dest, data[i], datalen[i]);
dest += datalen[i];
}
- error->data[n_data] = NULL;
+ error->data[n_data++] = NULL;
+
+ if (subsystem)
+ error->subsystem = strcpy(d_subsys, subsystem);
+
+ if (code)
+ error->code = strcpy(d_code, code);
}
static void
}
static void
@@
-170,8
+176,6
@@
interface_event(struct interface *iface, enum interface_event ev)
static void
interface_flush_state(struct interface *iface)
{
static void
interface_flush_state(struct interface *iface)
{
- if (iface->main_dev.dev)
- device_release(&iface->main_dev);
if (iface->l3_dev.dev)
device_release(&iface->l3_dev);
interface_data_flush(iface);
if (iface->l3_dev.dev)
device_release(&iface->l3_dev);
interface_data_flush(iface);
@@
-194,8
+198,6
@@
mark_interface_down(struct interface *iface)
void
__interface_set_down(struct interface *iface, bool force)
{
void
__interface_set_down(struct interface *iface, bool force)
{
- interface_clear_errors(iface);
-
if (iface->state == IFS_DOWN ||
iface->state == IFS_TEARDOWN)
return;
if (iface->state == IFS_DOWN ||
iface->state == IFS_TEARDOWN)
return;
@@
-395,7
+397,6
@@
interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
iface->state = IFS_UP;
iface->start_time = system_get_rtime();
interface_event(iface, IFEV_UP);
iface->state = IFS_UP;
iface->start_time = system_get_rtime();
interface_event(iface, IFEV_UP);
- interface_write_resolv_conf();
netifd_log_message(L_NOTICE, "Interface '%s' is now up\n", iface->name);
break;
case IFPEV_DOWN:
netifd_log_message(L_NOTICE, "Interface '%s' is now up\n", iface->name);
break;
case IFPEV_DOWN:
@@
-404,6
+405,8
@@
interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
mark_interface_down(iface);
netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
mark_interface_down(iface);
+ if (iface->main_dev.dev)
+ device_release(&iface->main_dev);
interface_handle_config_change(iface);
break;
case IFPEV_LINK_LOST:
interface_handle_config_change(iface);
break;
case IFPEV_LINK_LOST:
@@
-415,6
+418,8
@@
interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
iface->state = IFS_SETUP;
break;
}
iface->state = IFS_SETUP;
break;
}
+
+ interface_write_resolv_conf();
}
void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state)
}
void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state)