dutil_linux.{c,h}: Added modprobed_alias_bond, modprobed_unalias_bond
(earlier named modprobe_(un)alias_bond, renamed to point out that
they are using the modprobe.d file-tree)
drv_initscripts.c: Removed modprobe_alias_bond, modprobe_unalias_bond
---
src/drv_initscripts.c | 62 +-----------------------------------------------
src/dutil_linux.c | 58 +++++++++++++++++++++++++++++++++++++++++++++
src/dutil_linux.h | 9 +++++++
3 files changed, 69 insertions(+), 60 deletions(-)
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index dc8d471..0c69071 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -576,64 +576,6 @@ static int bridge_slaves(struct netcf *ncf, const char *name, char
***slaves) {
return -1;
}
-/* Add an 'alias NAME bonding' to an appropriate file in /etc/modprobe.d,
- * if none exists yet. If we need to create a new one, it goes into the
- * file netcf.conf.
- */
-static void modprobe_alias_bond(struct netcf *ncf, const char *name) {
- char *path = NULL;
- struct augeas *aug = get_augeas(ncf);
- int r, nmatches;
-
- nmatches = aug_fmt_match(ncf, NULL,
- "/files/etc/modprobe.d/*/alias[ . =
'%s']",
- name);
- ERR_BAIL(ncf);
-
- if (nmatches == 0) {
- /* Add a new alias node; this probably deserves better API support
- in Augeas, it's too convoluted */
- r = xasprintf(&path,
- "/files/etc/modprobe.d/netcf.conf/alias[last()]", name);
- ERR_COND_BAIL(r < 0, ncf, ENOMEM);
- nmatches = aug_match(aug, path, NULL);
- if (nmatches > 0) {
- r = aug_insert(aug, path, "alias", 0);
- ERR_COND_BAIL(r < 0, ncf, EOTHER);
- }
- r = aug_set(aug, path, name);
- FREE(path);
- }
-
- r = xasprintf(&path,
- "/files/etc/modprobe.d/*/alias[ . =
'%s']/modulename",
- name);
- ERR_COND_BAIL(r < 0, ncf, ENOMEM);
-
- r = aug_set(aug, path, "bonding");
- ERR_COND_BAIL(r < 0, ncf, EOTHER);
-
- error:
- FREE(path);
-}
-
-/* Remove the alias for NAME to the bonding module */
-static void modprobe_unalias_bond(struct netcf *ncf, const char *name) {
- char *path = NULL;
- struct augeas *aug = get_augeas(ncf);
- int r;
-
- r = xasprintf(&path,
- "/files/etc/modprobe.d/*/alias[ . = '%s'][modulename =
'bonding']",
- name);
- ERR_COND_BAIL(r < 0, ncf, ENOMEM);
-
- r = aug_rm(aug, path);
- ERR_COND_BAIL(r < 0, ncf, EOTHER);
- error:
- FREE(path);
-}
-
struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
xmlDocPtr ncf_xml = NULL, aug_xml = NULL;
char *name = NULL, *path = NULL;
@@ -666,7 +608,7 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
ERR_BAIL(ncf);
if (is_bond(ncf, name)) {
- modprobe_alias_bond(ncf, name);
+ modprobed_alias_bond(ncf, name);
ERR_BAIL(ncf);
}
@@ -696,7 +638,7 @@ int drv_undefine(struct netcf_if *nif) {
ERR_BAIL(ncf);
if (is_bond(ncf, nif->name)) {
- modprobe_unalias_bond(ncf, nif->name);
+ modprobed_unalias_bond(ncf, nif->name);
ERR_BAIL(ncf);
}
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index cd87d3b..4e99ef6 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -94,6 +94,64 @@ int aug_get_mac(struct netcf *ncf, const char *intf, const char **mac)
{
return r;
}
+/* Add an 'alias NAME bonding' to an appropriate file in /etc/modprobe.d,
+ * if none exists yet. If we need to create a new one, it goes into the
+ * file netcf.conf.
+ */
+void modprobed_alias_bond(struct netcf *ncf, const char *name) {
+ char *path = NULL;
+ struct augeas *aug = get_augeas(ncf);
+ int r, nmatches;
+
+ nmatches = aug_fmt_match(ncf, NULL,
+ "/files/etc/modprobe.d/*/alias[ . =
'%s']",
+ name);
+ ERR_BAIL(ncf);
+
+ if (nmatches == 0) {
+ /* Add a new alias node; this probably deserves better API support
+ in Augeas, it's too convoluted */
+ r = xasprintf(&path,
+ "/files/etc/modprobe.d/netcf.conf/alias[last()]", name);
+ ERR_COND_BAIL(r < 0, ncf, ENOMEM);
+ nmatches = aug_match(aug, path, NULL);
+ if (nmatches > 0) {
+ r = aug_insert(aug, path, "alias", 0);
+ ERR_COND_BAIL(r < 0, ncf, EOTHER);
+ }
+ r = aug_set(aug, path, name);
+ FREE(path);
+ }
+
+ r = xasprintf(&path,
+ "/files/etc/modprobe.d/*/alias[ . =
'%s']/modulename",
+ name);
+ ERR_COND_BAIL(r < 0, ncf, ENOMEM);
+
+ r = aug_set(aug, path, "bonding");
+ ERR_COND_BAIL(r < 0, ncf, EOTHER);
+
+ error:
+ FREE(path);
+}
+
+/* Remove the alias for NAME to the bonding module */
+void modprobed_unalias_bond(struct netcf *ncf, const char *name) {
+ char *path = NULL;
+ struct augeas *aug = get_augeas(ncf);
+ int r;
+
+ r = xasprintf(&path,
+ "/files/etc/modprobe.d/*/alias[ . = '%s'][modulename =
'bonding']",
+ name);
+ ERR_COND_BAIL(r < 0, ncf, ENOMEM);
+
+ r = aug_rm(aug, path);
+ ERR_COND_BAIL(r < 0, ncf, EOTHER);
+ error:
+ FREE(path);
+}
+
/*
* Local variables:
* indent-tabs-mode: nil
diff --git a/src/dutil_linux.h b/src/dutil_linux.h
index 7483459..0351b8b 100644
--- a/src/dutil_linux.h
+++ b/src/dutil_linux.h
@@ -29,6 +29,15 @@ int aug_match_mac(struct netcf *ncf, const char *mac, char
***matches);
/* Get the MAC address of the interface INTF */
int aug_get_mac(struct netcf *ncf, const char *intf, const char **mac);
+/* Add an 'alias NAME bonding' to an appropriate file in /etc/modprobe.d,
+ * if none exists yet. If we need to create a new one, it goes into the
+ * file netcf.conf.
+ */
+void modprobed_alias_bond(struct netcf *ncf, const char *name);
+
+/* Remove an 'alias NAME bonding' as created by modprobed_alias_bond */
+void modprobed_unalias_bond(struct netcf *ncf, const char *name);
+
#endif
/*
--
1.6.2