updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / netcf / netcf-0.1.7.patch
blobd4a4d31b73063d1b18f31947509d309b0b20e29f
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
4 @@ -47,9 +47,12 @@
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"/>
17 </xsl:template>
19 <xsl:template name='bare-vlan-interface'>
20 @@ -68,6 +71,7 @@
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}"/>
28 @@ -75,7 +79,11 @@
29 <xsl:if test="bridge/@delay">
30 <node label="DELAY" value="{bridge/@delay}"/>
31 </xsl:if>
32 + <node label="DHCP_TIMEOUT" value="0"/>
33 + <!--
34 + We don't have to define interfaces separately
35 </tree>
37 <xsl:for-each select='bridge/interface'>
38 <tree>
39 <xsl:if test="@type = 'ethernet'">
40 @@ -87,12 +95,29 @@
41 <xsl:if test="@type = 'bond'">
42 <xsl:call-template name="bare-bond-interface"/>
43 </xsl:if>
45 + BRIDGE_INTERFACES= is defined with all interfaces
46 <node label="BRIDGE" value="{../../@name}"/>
48 + <xsl:variable name="bridgeifaces" select="concat($bridgeifaces, '.', @name)"/>
49 </tree>
50 <xsl:if test="@type = 'bond'">
51 <xsl:call-template name="bond-slaves"/>
52 </xsl:if>
53 </xsl:for-each>
54 + -->
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(' ')"/>
61 + </xsl:for-each>
62 + <xsl:text></xsl:text>
63 + </xsl:attribute>
64 + </node>
65 + <!-- </xsl:if> -->
66 + </tree>
67 </xsl:template>
69 <!--
70 @@ -138,8 +163,8 @@
71 Named templates, following the Relax NG syntax
72 -->
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}"/>
78 </xsl:template>
80 <xsl:template name="mtu">
81 @@ -153,6 +178,7 @@
82 <xsl:if test="mac">
83 <node label="HWADDR" value="{mac/@address}"/>
84 </xsl:if>
85 + <node label="CONNECTION" value="{@type}"/>
86 <xsl:call-template name="startmode"/>
87 <xsl:call-template name="mtu"/>
88 </xsl:template>
89 @@ -184,14 +210,14 @@
90 <xsl:template name="protocol-ipv4">
91 <xsl:choose>
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}"/>
97 </xsl:if>
98 </xsl:when>
99 <xsl:when test="ip">
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)}"/>
106 </xsl:if>
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
110 @@ -47,7 +47,7 @@
111 </xsl:template>
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"/>
119 @@ -55,7 +55,7 @@
120 </xsl:template>
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, '.')"/>
127 <vlan tag="{$tag}">
128 @@ -70,7 +70,7 @@
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 @@
138 Bond
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"/>
143 <bond>
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"/>
147 </xsl:call-template>
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'/>
152 </xsl:for-each>
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'/>
156 </xsl:for-each>
157 </bond>
158 @@ -125,7 +125,7 @@
159 </xsl:template>
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"/>
167 @@ -154,7 +154,7 @@
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"/>
173 </xsl:attribute>
174 </xsl:template>
176 @@ -173,7 +173,7 @@
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">
185 @@ -186,7 +186,7 @@
186 </dhcp>
187 </xsl:when>
188 <xsl:when test="$uses_static">
189 - <ip address="{node[@label = 'IPADDR']/@value}">
190 + <ip address="{node[@label = 'ADDR']/@value}">
191 <xsl:choose>
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
197 @@ -49,17 +49,20 @@
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[] = {
212 /* Ifcfg files */
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 @@
222 int nmatches;
224 nmatches = aug_fmt_match(ncf, NULL,
225 - "%s[ DEVICE = '%s'"
226 + "%s[ INTERFACE = '%s'"
227 " or BRIDGE = '%s'"
228 " or MASTER = '%s'"
229 - " or MASTER = ../*[BRIDGE = '%s']/DEVICE ]/DEVICE",
230 + " or MASTER = ../*[BRIDGE = '%s']/INTERFACE ]/INTERFACE",
231 ifcfg_path, name, name, name, name);
232 return nmatches > 0;
234 @@ -173,7 +176,7 @@
235 aug = get_augeas(ncf);
236 ERR_BAIL(ncf);
238 - ndevs = aug_fmt_match(ncf, &devs, "%s[DEVICE = '%s']",
239 + ndevs = aug_fmt_match(ncf, &devs, "%s[INTERFACE = '%s']",
240 ifcfg_path, name);
241 ERR_COND_BAIL(ndevs < 0, ncf, EOTHER);
243 @@ -296,7 +299,8 @@
244 int result = 0, ndevs;
245 char **devs = NULL;
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) {
267 @@ -599,8 +603,8 @@
269 ncf = nif->ncf;
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);
276 ERR_BAIL(ncf);
278 @@ -745,7 +749,7 @@
279 int nmatches = 0;
281 nmatches = aug_fmt_match(ncf, NULL,
282 - "%s[ DEVICE = '%s' and TYPE = 'Bridge']",
283 + "%s[ INTERFACE = '%s' and TYPE = 'Bridge']",
284 ifcfg_path, name);
285 return nmatches > 0;
287 @@ -758,7 +762,7 @@
288 ERR_BAIL(ncf);
290 nslaves = aug_fmt_match(ncf, slaves,
291 - "%s[ BRIDGE = '%s' ]/DEVICE", ifcfg_path, name);
292 + "%s[ BRIDGE = '%s' ]/INTERFACE", ifcfg_path, name);
293 ERR_BAIL(ncf);
294 for (int i=0; i < nslaves; i++) {
295 char *p = (*slaves)[i];
296 @@ -790,8 +794,8 @@
297 /* The last or clause catches slaves of a bond that are enslaved to
298 * a bridge NAME */
299 r = xasprintf(&path,
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);
307 @@ -967,7 +971,7 @@
308 for (int i = 0; i < nmatches; i++) {
309 if (!has_ifcfg_file(ncf, matches[i]))
310 continue;
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;
327 int nslaves = 0;
328 @@ -1035,11 +1042,24 @@
329 ERR_BAIL(ncf);
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
336 + };
338 + run_program(ncf, argv);
339 ERR_BAIL(ncf);
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
349 + };
351 + run_program(ncf, argv);
352 ERR_BAIL(ncf);
353 result = 0;
354 error:
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;
366 int nslaves = 0;
367 int result = -1;
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
375 + };
377 + run_program(ncf, argv);
378 ERR_BAIL(ncf);
379 if (is_bridge(ncf, nif->name)) {
380 /* Bring up bridge slaves after the bridge */
381 @@ -1062,7 +1092,12 @@
382 ERR_BAIL(ncf);
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
389 + };
391 + run_program(ncf, argvs);
392 ERR_BAIL(ncf);
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
398 @@ -2,10 +2,12 @@
399 <start mode="onboot"/>
400 <mtu size="1500"/>
401 <protocol family="ipv4">
402 - <ip address="192.168.80.5" prefix="24"/>
403 + <dhcp/>
404 </protocol>
405 <bridge stp="off" delay="0.01">
406 <interface type="ethernet" name="eth0">
407 + <mac address="ab:bb:cc:dd:ee:ff"/>
408 </interface>
409 + <interface type="ethernet" name="eth1"/>
410 </bridge>
411 </interface>
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
415 @@ -1,9 +1,9 @@
416 -<interface type="vlan" name="eth1.42">
417 +<interface type="vlan" name="eth0.42">
418 <start mode="onboot"/>
419 <protocol family="ipv4">
420 <dhcp peerdns="no"/>
421 </protocol>
422 <vlan tag="42">
423 - <interface name="eth1"/>
424 + <interface name="eth0"/>
425 </vlan>
426 </interface>