1 diff -ur netcf-0.1.7.ori//data/xml/initscripts-get.xsl netcf-0.1.7/data/xml/initscripts-get.xsl
2 --- netcf-0.1.7.ori//data/xml/initscripts-get.xsl 2009-10-04 08:18:41.000000000 +0200
3 +++ netcf-0.1.7/data/xml/initscripts-get.xsl 2010-12-08 14:54:28.891813397 +0100
5 <xsl:template name="vlan-interface-common">
6 <xsl:variable name="iface" select="concat(vlan/interface/@name, '.', vlan/@tag)"/>
8 - <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
9 - <node label="DEVICE" value="{$iface}"/>
10 - <node label="VLAN" value="yes"/>
11 + <xsl:attribute name="path">/files/etc/network.d/ifcfg-<xsl:value-of select="$iface"/></xsl:attribute>
12 + <node label="INTERFACE" value="{$iface}"/>
13 + <node label="PHYS_INTERFACE" value="{vlan/interface/@name}"/>
14 + <node label="VLAN" value="{vlan/@tag}"/>
15 + <node label="CONNECTION" value="ethernet-iproute-vlan"/>
16 + <node label="FLAG" value="false"/>
19 <xsl:template name='bare-vlan-interface'>
21 <xsl:call-template name="startmode"/>
22 <xsl:call-template name="mtu"/>
23 <node label="TYPE" value="Bridge"/>
24 + <node label="CONNECTION" value="bridge"/>
25 <xsl:call-template name="interface-addressing"/>
26 <xsl:if test="bridge/@stp">
27 <node label="STP" value="{bridge/@stp}"/>
29 <xsl:if test="bridge/@delay">
30 <node label="DELAY" value="{bridge/@delay}"/>
32 + <node label="DHCP_TIMEOUT" value="0"/>
34 + We don't have to define interfaces separately
37 <xsl:for-each select='bridge/interface'>
39 <xsl:if test="@type = 'ethernet'">
41 <xsl:if test="@type = 'bond'">
42 <xsl:call-template name="bare-bond-interface"/>
45 + BRIDGE_INTERFACES= is defined with all interfaces
46 <node label="BRIDGE" value="{../../@name}"/>
48 + <xsl:variable name="bridgeifaces" select="concat($bridgeifaces, '.', @name)"/>
50 <xsl:if test="@type = 'bond'">
51 <xsl:call-template name="bond-slaves"/>
55 + <!-- <xsl:if test="count(ip) > 1"> -->
56 + <node label="BRIDGE_INTERFACES">
57 + <xsl:attribute name="value">
58 + <xsl:text></xsl:text>
59 + <xsl:for-each select="bridge/interface">
60 + <xsl:value-of select="@name"/><xsl:value-of select="string(' ')"/>
62 + <xsl:text></xsl:text>
71 Named templates, following the Relax NG syntax
73 <xsl:template name="name-attr">
74 - <xsl:attribute name="path">/files/etc/sysconfig/network-scripts/ifcfg-<xsl:value-of select="@name"/></xsl:attribute>
75 - <node label="DEVICE" value="{@name}"/>
76 + <xsl:attribute name="path">/files/etc/network.d/ifcfg-<xsl:value-of select="@name"/></xsl:attribute>
77 + <node label="INTERFACE" value="{@name}"/>
80 <xsl:template name="mtu">
83 <node label="HWADDR" value="{mac/@address}"/>
85 + <node label="CONNECTION" value="{@type}"/>
86 <xsl:call-template name="startmode"/>
87 <xsl:call-template name="mtu"/>
90 <xsl:template name="protocol-ipv4">
92 <xsl:when test="dhcp">
93 - <node label="BOOTPROTO" value="dhcp"/>
94 + <node label="IP" value="dhcp"/>
95 <xsl:if test="dhcp/@peerdns">
96 <node label="PEERDNS" value="{dhcp/@peerdns}"/>
100 - <node label="BOOTPROTO" value="none"/>
101 - <node label="IPADDR" value="{ip/@address}"/>
102 + <node label="IP" value="static"/>
103 + <node label="ADDR" value="{ip/@address}"/>
104 <xsl:if test="ip/@prefix">
105 <node label="NETMASK" value="{ipcalc:netmask(ip/@prefix)}"/>
107 diff -ur netcf-0.1.7.ori//data/xml/initscripts-put.xsl netcf-0.1.7/data/xml/initscripts-put.xsl
108 --- netcf-0.1.7.ori//data/xml/initscripts-put.xsl 2009-10-04 08:18:41.000000000 +0200
109 +++ netcf-0.1.7/data/xml/initscripts-put.xsl 2010-11-26 10:44:46.133757628 +0100
113 <xsl:template name="bare-vlan-interface">
114 - <xsl:variable name="name" select="node[@label = 'DEVICE']/@value"/>
115 + <xsl:variable name="name" select="node[@label = 'INTERFACE']/@value"/>
116 <interface type="vlan">
117 <xsl:call-template name="name-attr"/>
118 <xsl:call-template name="vlan-device"/>
122 <xsl:template name="vlan-device">
123 - <xsl:variable name="name" select="node[@label = 'DEVICE']/@value"/>
124 + <xsl:variable name="name" select="node[@label = 'INTERFACE']/@value"/>
125 <xsl:variable name="device" select="substring-before($name, '.')"/>
126 <xsl:variable name="tag" select="substring-after($name, '.')"/>
129 match="tree[node[@label = 'TYPE' and @value = 'Bridge']]">
130 <interface type="bridge">
131 <!-- the bridge node itself -->
132 - <xsl:variable name="iface" select="node[@label= 'DEVICE']/@value"/>
133 + <xsl:variable name="iface" select="node[@label= 'INTERFACE']/@value"/>
134 <xsl:call-template name="name-attr"/>
135 <xsl:call-template name="startmode"/>
136 <xsl:call-template name="mtu"/>
137 @@ -101,17 +101,17 @@
140 <xsl:template name="bond-element">
141 - <xsl:variable name="iface" select="node[@label= 'DEVICE']/@value"/>
142 + <xsl:variable name="iface" select="node[@label= 'INTERFACE']/@value"/>
144 <xsl:variable name="opts" select="node[@label = 'BONDING_OPTS']/@value"/>
145 <xsl:call-template name="bonding-opts">
146 <xsl:with-param name="opts" select="$opts"/>
148 <xsl:variable name="primary" select="bond:option($opts, 'primary')"/>
149 - <xsl:for-each select="/descendant-or-self::*[node[@label = 'MASTER' and @value = $iface]][node[@label = 'DEVICE' and @value = $primary]]">
150 + <xsl:for-each select="/descendant-or-self::*[node[@label = 'MASTER' and @value = $iface]][node[@label = 'INTERFACE' and @value = $primary]]">
151 <xsl:call-template name='bare-ethernet-interface'/>
153 - <xsl:for-each select="/descendant-or-self::*[node[@label = 'MASTER' and @value = $iface]][node[@label = 'DEVICE' and @value != $primary]]">
154 + <xsl:for-each select="/descendant-or-self::*[node[@label = 'MASTER' and @value = $iface]][node[@label = 'INTERFACE' and @value != $primary]]">
155 <xsl:call-template name='bare-ethernet-interface'/>
161 <xsl:template name="bond-interface"
162 - match="tree[node[@label = 'DEVICE'][@value = //tree/node[@label = 'MASTER']/@value]][count(node[@label = 'BRIDGE']) = 0]">
163 + match="tree[node[@label = 'INTERFACE'][@value = //tree/node[@label = 'MASTER']/@value]][count(node[@label = 'BRIDGE']) = 0]">
164 <interface type="bond">
165 <xsl:call-template name="name-attr"/>
166 <xsl:call-template name="startmode"/>
169 <xsl:template name="name-attr">
170 <xsl:attribute name="name">
171 - <xsl:value-of select="node[@label= 'DEVICE']/@value"/>
172 + <xsl:value-of select="node[@label= 'INTERFACE']/@value"/>
177 <xsl:variable name="uses_dhcp"
178 select="node[@label = 'BOOTPROTO']/@value = 'dhcp'"/>
179 <xsl:variable name="uses_static"
180 - select="count(node[@label = 'IPADDR']) > 0"/>
181 + select="count(node[@label = 'ADDR']) > 0"/>
182 <xsl:variable name="uses_ipv4" select="$uses_dhcp or $uses_static"/>
183 <xsl:if test="$uses_ipv4">
184 <protocol family="ipv4">
188 <xsl:when test="$uses_static">
189 - <ip address="{node[@label = 'IPADDR']/@value}">
190 + <ip address="{node[@label = 'ADDR']/@value}">
192 <xsl:when test="node[@label = 'PREFIX']">
193 <xsl:attribute name="prefix"><xsl:value-of select="node[@label = 'PREFIX']/@value"/></xsl:attribute>
194 diff -ur netcf-0.1.7.ori//src/drv_initscripts.c netcf-0.1.7/src/drv_initscripts.c
195 --- netcf-0.1.7.ori//src/drv_initscripts.c 2010-09-23 14:13:13.000000000 +0200
196 +++ netcf-0.1.7/src/drv_initscripts.c 2010-12-08 13:57:02.027361706 +0100
198 #include <libexslt/exslt.h>
200 static const char *const network_scripts_path =
201 - "/files/etc/sysconfig/network-scripts";
202 + //"/files/etc/sysconfig/network-scripts";
203 + "/files/etc/network.d/*";
205 static const char *const ifcfg_path =
206 - "/files/etc/sysconfig/network-scripts/*";
207 + //"/files/etc/sysconfig/network-scripts/*";
208 + "/files/etc/network.d/*";
210 /* Augeas should only load the files we are interested in */
211 static const struct augeas_pv augeas_xfm_common_pv[] = {
213 { "/augeas/load/Ifcfg/lens", "Sysconfig.lns" },
214 { "/augeas/load/Ifcfg/incl",
215 - "/etc/sysconfig/network-scripts/ifcfg-*" },
216 + "/etc/network.d/ifcfg-*" },
217 + //"/etc/sysconfig/network-scripts/ifcfg-*" },
218 { "/augeas/load/Ifcfg/excl[1]", "*~" },
219 { "/augeas/load/Ifcfg/excl[2]", "*.bak" },
220 { "/augeas/load/Ifcfg/excl[3]", "*.orig" },
221 @@ -107,10 +110,10 @@
224 nmatches = aug_fmt_match(ncf, NULL,
225 - "%s[ DEVICE = '%s'"
226 + "%s[ INTERFACE = '%s'"
229 - " or MASTER = ../*[BRIDGE = '%s']/DEVICE ]/DEVICE",
230 + " or MASTER = ../*[BRIDGE = '%s']/INTERFACE ]/INTERFACE",
231 ifcfg_path, name, name, name, name);
235 aug = get_augeas(ncf);
238 - ndevs = aug_fmt_match(ncf, &devs, "%s[DEVICE = '%s']",
239 + ndevs = aug_fmt_match(ncf, &devs, "%s[INTERFACE = '%s']",
241 ERR_COND_BAIL(ndevs < 0, ncf, EOTHER);
244 int result = 0, ndevs;
247 - ndevs = aug_fmt_match(ncf, &devs, "%s/DEVICE", ifcfg_path);
248 + ndevs = aug_fmt_match(ncf, &devs, "%s/INTERFACE", ifcfg_path);
249 + printf("%i\n", ndevs);
250 ERR_COND_BAIL(ndevs < 0, ncf, EOTHER);
252 result = uniq_ifcfg_paths(ncf, ndevs, devs, intf);
253 @@ -453,11 +457,11 @@
255 int drv_list_interfaces(struct netcf *ncf, int maxnames, char **names,
256 unsigned int flags) {
257 - return list_interface_ids(ncf, maxnames, names, flags, "DEVICE");
258 + return list_interface_ids(ncf, maxnames, names, flags, "INTERFACE");
261 int drv_num_of_interfaces(struct netcf *ncf, unsigned int flags) {
262 - return list_interface_ids(ncf, 0, NULL, flags, "DEVICE");
263 + return list_interface_ids(ncf, 0, NULL, flags, "INTERFACE");
266 struct netcf_if *drv_lookup_by_name(struct netcf *ncf, const char *name) {
270 ndevs = aug_fmt_match(ncf, &devs,
271 - "%s[ DEVICE = '%s' or BRIDGE = '%s' or MASTER = '%s'"
272 - " or MASTER = ../*[BRIDGE = '%s']/DEVICE ]/DEVICE",
273 + "%s[ INTERFACE = '%s' or BRIDGE = '%s' or MASTER = '%s'"
274 + " or MASTER = ../*[BRIDGE = '%s']/INTERFACE ]/INTERFACE",
275 ifcfg_path, nif->name, nif->name, nif->name, nif->name);
281 nmatches = aug_fmt_match(ncf, NULL,
282 - "%s[ DEVICE = '%s' and TYPE = 'Bridge']",
283 + "%s[ INTERFACE = '%s' and TYPE = 'Bridge']",
290 nslaves = aug_fmt_match(ncf, slaves,
291 - "%s[ BRIDGE = '%s' ]/DEVICE", ifcfg_path, name);
292 + "%s[ BRIDGE = '%s' ]/INTERFACE", ifcfg_path, name);
294 for (int i=0; i < nslaves; i++) {
295 char *p = (*slaves)[i];
297 /* The last or clause catches slaves of a bond that are enslaved to
300 - "%s[ DEVICE = '%s' or BRIDGE = '%s' or MASTER = '%s' "
301 - " or MASTER = ../*[BRIDGE = '%s']/DEVICE ]",
302 + "%s[ INTERFACE = '%s' or BRIDGE = '%s' or MASTER = '%s' "
303 + " or MASTER = ../*[BRIDGE = '%s']/INTERFACE ]",
304 ifcfg_path, name, name, name, name);
305 ERR_NOMEM(r < 0, ncf);
308 for (int i = 0; i < nmatches; i++) {
309 if (!has_ifcfg_file(ncf, matches[i]))
311 - r = xasprintf(&ifcfg, "%s[DEVICE = '%s']", ifcfg_path, matches[i]);
312 + r = xasprintf(&ifcfg, "%s[INTERFACE = '%s']", ifcfg_path, matches[i]);
313 ERR_NOMEM(r < 0, ncf);
315 if (! is_slave(ncf, ifcfg))
316 @@ -1023,7 +1027,10 @@
319 int drv_if_up(struct netcf_if *nif) {
320 - static const char *const ifup = "ifup";
321 + //static const char *const ifup = "ifup";
322 + static const char *const ifup = "netcfg";
323 + static const char *const ifprefix = "ifcfg-";
324 + char ifname[strlen(nif->name) + sizeof(ifprefix)];
325 struct netcf *ncf = nif->ncf;
326 char **slaves = NULL;
328 @@ -1035,11 +1042,24 @@
331 for (int i=0; i < nslaves; i++) {
332 - run1(ncf, ifup, slaves[i]);
333 + //run1(ncf, ifup, slaves[i]);
334 + const char *const argv[] = {
335 + ifup, "-u", slaves[i], NULL
338 + run_program(ncf, argv);
342 - run1(ncf, ifup, nif->name);
343 + //run1(ncf, ifup, nif->name);
344 + /* Interfaces name have to be equal to script under /etc/network.d */
345 + strcpy(ifname, ifprefix);
346 + strcat(ifname, nif->name);
347 + const char *const argv[] = {
348 + ifup, "-u", ifname, NULL
351 + run_program(ncf, argv);
355 @@ -1048,13 +1068,23 @@
358 int drv_if_down(struct netcf_if *nif) {
359 - static const char *const ifdown = "ifdown";
360 + //static const char *const ifdown = "ifdown";
361 + static const char *const ifdown = "netcfg";
362 + static const char *const ifprefix = "ifcfg-";
363 + char ifname[strlen(nif->name) + sizeof(ifprefix)];
364 struct netcf *ncf = nif->ncf;
365 char **slaves = NULL;
369 - run1(ncf, ifdown, nif->name);
370 + //run1(ncf, ifdown, nif->name);
371 + strcpy(ifname, ifprefix);
372 + strcat(ifname, nif->name);
373 + const char *const argv[] = {
374 + ifdown, "-d", ifname, NULL
377 + run_program(ncf, argv);
379 if (is_bridge(ncf, nif->name)) {
380 /* Bring up bridge slaves after the bridge */
381 @@ -1062,7 +1092,12 @@
384 for (int i=0; i < nslaves; i++) {
385 - run1(ncf, ifdown, slaves[i]);
386 + //run1(ncf, ifdown, slaves[i]);
387 + const char *const argvs[] = {
388 + ifdown, "-d", slaves[i], NULL
391 + run_program(ncf, argvs);
395 diff -ur netcf-0.1.7.ori//tests/interface/bridge.xml~ netcf-0.1.7/tests/interface/bridge.xml~
396 --- netcf-0.1.7.ori//tests/interface/bridge.xml~ 2009-10-13 19:14:53.000000000 +0200
397 +++ netcf-0.1.7/tests/interface/bridge.xml~ 2009-10-14 05:09:05.000000000 +0200
399 <start mode="onboot"/>
401 <protocol family="ipv4">
402 - <ip address="192.168.80.5" prefix="24"/>
405 <bridge stp="off" delay="0.01">
406 <interface type="ethernet" name="eth0">
407 + <mac address="ab:bb:cc:dd:ee:ff"/>
409 + <interface type="ethernet" name="eth1"/>
412 diff -ur netcf-0.1.7.ori//tests/interface/vlan.xml~ netcf-0.1.7/tests/interface/vlan.xml~
413 --- netcf-0.1.7.ori//tests/interface/vlan.xml~ 2010-07-30 06:02:39.000000000 +0200
414 +++ netcf-0.1.7/tests/interface/vlan.xml~ 2010-09-07 18:26:22.000000000 +0200
416 -<interface type="vlan" name="eth1.42">
417 +<interface type="vlan" name="eth0.42">
418 <start mode="onboot"/>
419 <protocol family="ipv4">
423 - <interface name="eth1"/>
424 + <interface name="eth0"/>