summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-11-25 01:33:04 +0100
committerTom Gundersen <teg@jklm.no>2013-11-25 14:53:56 +0100
commitd2df0d0ed3a88e491405b403e6022e6619750130 (patch)
treed9bccbc34a4c2283403498b9b7ca7ce0d702a6c7 /src/shared
parent517dcac840fe8d5bf30a05c0084eff219af10a4a (diff)
udev: net_setup_link - don't use Description as Alias
Use Description only internally, and allow Alias to be set as a separate option. For instance SNMP uses ifalias for a specific purpose, so let's not write to it by default.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/net-util.c42
-rw-r--r--src/shared/net-util.h4
2 files changed, 45 insertions, 1 deletions
diff --git a/src/shared/net-util.c b/src/shared/net-util.c
index 2734d119ce..f2fd0819d3 100644
--- a/src/shared/net-util.c
+++ b/src/shared/net-util.c
@@ -20,7 +20,7 @@
***/
#include <netinet/ether.h>
-#include <net/if.h>
+#include <linux/if.h>
#include <arpa/inet.h>
#include "net-util.h"
@@ -123,6 +123,46 @@ int config_parse_ifname(const char *unit,
return 0;
}
+int config_parse_ifalias(const char *unit,
+ const char *filename,
+ unsigned line,
+ const char *section,
+ const char *lvalue,
+ int ltype,
+ const char *rvalue,
+ void *data,
+ void *userdata) {
+
+ char **s = data;
+ char *n;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ n = strdup(rvalue);
+ if (!n)
+ return log_oom();
+
+ if (!ascii_is_valid(n) || strlen(n) >= IFALIASZ) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Interface alias is not ASCII clean or is too long, ignoring assignment: %s", rvalue);
+ free(n);
+ return 0;
+ }
+
+ free(*s);
+ if (*n)
+ *s = n;
+ else {
+ free(n);
+ *s = NULL;
+ }
+
+ return 0;
+}
+
int config_parse_hwaddr(const char *unit,
const char *filename,
unsigned line,
diff --git a/src/shared/net-util.h b/src/shared/net-util.h
index eac394bffa..d6ca737e7f 100644
--- a/src/shared/net-util.h
+++ b/src/shared/net-util.h
@@ -43,4 +43,8 @@ int config_parse_ifname(const char *unit, const char *filename, unsigned line,
const char *section, const char *lvalue, int ltype,
const char *rvalue, void *data, void *userdata);
+int config_parse_ifalias(const char *unit, const char *filename, unsigned line,
+ const char *section, const char *lvalue, int ltype,
+ const char *rvalue, void *data, void *userdata);
+
int net_parse_inaddr(const char *address, unsigned char *family, void *dst);