[PATCH 1/3] build: ignore generated file
by Eric Blake
* .gitignore: Exclude netcf-transaction.init.
---
.gitignore | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8918703..310a773 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@ src/datadir.h
src/ncftool
src/ncftransform
src/netcf.syms
+src/netcf-transaction.init
tests/test-initscripts
*.aux
*.dvi
--
1.7.4.4
12 years, 9 months
[PATCH] Always add <bridge> element to bridge if, even if no physdev is attached
by Laine Stump
This patch resolves the following bug filed against RHEL:
https://bugzilla.redhat.com/show_bug.cgi?id=713180
If a bridge has no physical devices attached, ncf_if_xml_state() had
not been adding a <bridge> element to the returned XML. However,
<bridge> is required by the grammer if the interface is of
type="bridge" (even if it's empty), and libvirt enforces that.
The solution is to add in the <bridge> element *before* checking to
see if there are any physical devices attached.
---
src/dutil_linux.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index 0979a40..841c2a1 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -1022,13 +1022,16 @@ static void add_bridge_info(struct netcf *ncf,
int nphys, ii;
xmlNodePtr bridge_node = NULL, interface_node = NULL;
+ /* The <bridge> element is required by the grammar, so always add
+ * it, even if there are no physical devices attached.
+ */
+ bridge_node = xml_node(doc, root, "bridge");
+ ERR_NOMEM(bridge_node == NULL, ncf);
+
nphys = if_bridge_phys_name(ncf, ifname, &phys_names);
if (nphys <= 0)
return;
- bridge_node = xml_node(doc, root, "bridge");
- ERR_NOMEM(bridge_node == NULL, ncf);
-
for (ii = 0; ii < nphys; ii++) {
int phys_ifindex;
--
1.7.3.4
12 years, 9 months
[PATCH] Don't log error if interface isn't found in kernel during status report
by Laine Stump
This patch resolves the following bug reports:
https://bugzilla.redhat.com/show_bug.cgi?id=713286 (RHEL)
https://bugzilla.redhat.com/show_bug.cgi?id=698108 (Fedora)
There are many situations that will result in the config files for an
interface being present, but the interface not being found in the
kernel's list of interfaces. For example, if a bridge interface has
been ifdowned, it will not exist at all. Another case is an "alias
interface" (eg "eth0:1", which is not really an interface on its own,
but just an obsolete method of specifying a 2nd (or more) IP address
for a single interface. (In the example given, the config files will
talk about the interface "eth0:1", but the kernel only knows about
"eth0".)
If we return an error status any time ncf_if_xml_state() can't find an
interface in the kernel, then management applications that
periodically poll netcf for the status of all system interfaces will
quickly collect scads of error log messages.
The solution is to ignore failure to find an interface in the kernel
(which in this situation is really just one more piece of information
about the interface's status), and just not fill in the information
that would have otherwise been gathered.
---
src/dutil_linux.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index a829c37..0979a40 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -908,6 +908,10 @@ static void add_ethernet_info(struct netcf *ncf,
= { doc, root, NULL, ncf };
struct rtnl_link *filter_link = NULL;
+ /* if interface isn't currently available, nothing to add */
+ if (ifindex != RTNL_LINK_NOT_FOUND)
+ return;
+
filter_link = rtnl_link_alloc();
ERR_NOMEM(filter_link == NULL, ncf);
@@ -993,6 +997,10 @@ static void add_vlan_info(struct netcf *ncf,
= { doc, root, NULL, ncf };
struct rtnl_link *filter_link = NULL;
+ /* if interface isn't currently available, nothing to add */
+ if (ifindex != RTNL_LINK_NOT_FOUND)
+ return;
+
filter_link = rtnl_link_alloc();
ERR_NOMEM(filter_link == NULL, ncf);
@@ -1030,10 +1038,12 @@ static void add_bridge_info(struct netcf *ncf,
/* Add in type-specific info of physical interface */
phys_ifindex =
rtnl_link_name2i(ncf->driver->link_cache, phys_names[ii]);
- ERR_THROW((phys_ifindex == RTNL_LINK_NOT_FOUND), ncf, ENETLINK,
- "couldn't find ifindex for physical interface `%s` of bridge %s",
- phys_names[ii], ifname);
-
+ /* We ignore an error return here, because that usually just
+ * means the interface isn't currently running. The
+ * type-specific functions will recognize this from the
+ * invalid ifindex we pass to them, and "do the right thing"
+ * (which is usually, but not always, to silently return).
+ */
add_type_specific_info(ncf, phys_names[ii], phys_ifindex, doc,
interface_node);
}
@@ -1099,6 +1109,10 @@ static void add_bond_info(struct netcf *ncf,
struct nl_bond_callback_data cb_data
= { doc, root, NULL, ifindex, ncf };
+ /* if interface isn't currently available, nothing to add */
+ if (ifindex != RTNL_LINK_NOT_FOUND)
+ return;
+
nl_cache_foreach(ncf->driver->link_cache, add_bond_info_cb, &cb_data);
}
@@ -1163,9 +1177,12 @@ void add_state_to_xml_doc(struct netcf_if *nif, xmlDocPtr doc) {
"failed to refill interface address cache");
ifindex = rtnl_link_name2i(nif->ncf->driver->link_cache, nif->name);
- ERR_THROW((ifindex == RTNL_LINK_NOT_FOUND), nif->ncf, ENETLINK,
- "couldn't find ifindex for interface `%s`", nif->name);
-
+ /* We ignore an error return here, because that usually just
+ * means the interface isn't currently running. The
+ * type-specific functions will recognize this from the
+ * invalid ifindex we pass to them, and "do the right thing"
+ * (which is usually, but not always, to silently return).
+ */
add_type_specific_info(nif->ncf, nif->name, ifindex, doc, root);
ERR_BAIL(nif->ncf);
--
1.7.3.4
12 years, 9 months
[NetCF] #2: Error messages
by fedora-badges
#2: Error messages
-------------------------+--------------------------------------------------
Reporter: fab | Owner: lutter
Type: enhancement | Status: new
Priority: major | Milestone: next
Component: netcf | Version: devel
Keywords: |
-------------------------+--------------------------------------------------
It would be nice if netcf would be able to be a bit more specific about
the problem when a command failed. E.g.
{{{
ncftool> define bridge.xml
Failed to read bridge.xml
}}}
Is the file not found, is file not well-formatted, and so on.
--
Ticket URL: <https://fedorahosted.org/netcf/ticket/2>
NetCF <http://fedorahosted.org/netcf>
A cross-platform library for configuring network interfaces
12 years, 9 months
allow C++ linking
by Aleix Conchillo
Hi,
the patch at the end allows buidling c++ applications against netcf.
Otherwise, this is needed in the C++ code
extern "C" {
#include <netcf.h>
}
Thanks for this library!
Aleix
---------------
--- a/src/netcf.h
+++ b/src/netcf.h
@@ -81,6 +81,9 @@ typedef enum {
NETCF_IFACE_ACTIVE = 2, /* match up interfaces */
} netcf_if_flag_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* Initialize netcf. This function must be called before any other netcf
@@ -223,6 +226,11 @@ void ncf_if_free(struct netcf_if *);
* next call to another function in this API.
*/
int ncf_error(struct netcf *, const char **errmsg, const char **details);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
12 years, 9 months
[PATCH] Fix memory leak in drv_init
by Laine Stump
From: Osier Yang <jyang(a)redhat.com>
(Osier was unable to send this to the list, so I'm sending it for him,
and simultaneously ACKing it.)
* src/drv_initscripts.c: "goto error" instead of "return -1", as
"add_augeas_xfm_table" has already done some initialization on
ncf->driver.
---
AUTHORS | 1 +
src/drv_initscripts.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 032b020..9e90585 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -10,3 +10,4 @@ Contributions by:
Daniel Berrange <berrange(a)redhat.com>
Cole Robinson <crobinso(a)redhat.com>
Eric Blake <eblake(a)redhat.com>
+ Osier Yang <jyang(a)redhat.com>
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index 90434e4..7b2930d 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -355,7 +355,7 @@ int drv_init(struct netcf *ncf) {
if (stat(ncf->root, &stats) != 0 || !S_ISDIR(stats.st_mode)) {
report_error(ncf, NETCF_EFILE,
"invalid root '%s' is not a directory", ncf->root);
- return -1;
+ goto error;
}
// FIXME: Check for errors
--
1.7.3.4
12 years, 9 months
Re: [netcf-devel] [virt-tools-list] Several problems with the management of network interface. (virsh iface-define, virsh iface-start and with virt-manager)
by Cole Robinson
cc-ing netcf-devel
On 06/05/2011 11:09 AM, Lionel Schaub wrote:
> I have already post this bug here
> https://bugzilla.redhat.com/show_bug.cgi?id=709734
>
> but I did not answer.
>
>
>
>
>
> Description of problem:
>
> 1. The execution of the command "virsh iface-start br1" (br1 interface is
>
> obtained with "virsh iface-define") takes 10 minutes.
>
> 2. After restarting the machine, the interface does not start automatically
>
> even though I specified the parameter <start mode="onboot"/>. I have to
>
> manually run the command "virsh iface-start br1".
>
>
>
> If I create the interface with virt-manager, I have the same problems and
> the
>
> process takes about 20 minutes.
>
>
>
>
>
> Version-Release number of selected component:
> I have found the 0.8.8 version of libvirt and virsh in this repository:
> <https://fedoraproject.org/wiki/Virtualization_Preview_Repository>
> https://fedoraproject.org/wiki/Virtualization_Preview_Repository.
> I use this version because the 0.8.3 has a third bug.
>
> Fedora 14
>
> Linux Kernel 2.6.35.13-91.fc14.x86_64
>
> libvirt 0.8.8
>
> virsh 0.8.8
>
> virt-manager 0.8.7
>
> bridge-utils 1.2
>
>
>
>
>
> Steps to Reproduce:
>
> 1. Create the file bridgeInterfaceConfig.xml (change interface, ip and mac
> to
>
> correspond to your configuration)
>
> <interface type='bridge' name='br1'>
>
> <start mode="onboot"/>
>
> <protocol family='ipv4'>
>
> <ip address='192.168.1.15' prefix='24'/>
>
> </protocol>
>
> <bridge>
>
> <interface type='ethernet' name='eth2'>
>
> <mac address='00:1b:21:43:36:b0'/>
>
> </interface>
>
> </bridge>
>
> </interface>
>
> 2. launch "virsh iface-define bridgeInterfaceConfig.xml"
>
> 3. launch "iface-start br1". this step take 10 minutes.
>
> 4. restart the computer and see that the br1 interface no longer exists.
>
> 5. you can do the same with virt-manager.
>
12 years, 9 months
ANNOUNCE: netcf-0.1.8
by Laine Stump
I'm happy to announce the release of netcf 0.1.8
Here's a list of the changes in this release:
* New transactional change APIs: ncf_change_(begin|commit|rollback)
These new functions allow rolling back all changes made to the network
config since a particular checkpoint. If the changes haven't been
"committed"
by the time the system is rebooted, they will automatically be
rolled back at
boot time via a new initscript that is executed prior to bringing up
networking.
* Add stdout/stderr to error text when an external program fails
This allows us to deliver a more informative error message when
/sbin/ifup fails,
for example.
* make error reporting of failed execs more exact/correct
* Add "--system" to autogen.sh - sets all directories for standard
system install.
* Change sysconfdir and localstatedir during config if basedir is /usr.
* Remove unnecessary "Requires" of libxml2 and augeas from pkgconfig file
to pulling in extra packages when building an application that uses
netcf.
* Reorganize code to simplify porting to other platforms.
Although netcf was always intended to be ported to platforms other than
the original RHEL and Fedora, a couple of attempts at doing this have
pointed out that a lot of platform specific and platform independent code
was mixed together. I've made some attempts to clear that up.
This is an interim release to allow early use of the new ncf_change_*()
APIs. They currently function properly in terms of modifying/restoring
the files, but ncf_change_rollback doesn't yet update the live interface
state. That functionality will be added in the next few weeks, and
another release will be made sometime in early July.
Tarball:https://fedorahosted.org/released/netcf/netcf-0.1.8.tar.gz
GPG signature[1]:
https://fedorahosted.org/released/netcf/netcf-0.1.8.tar.gz.sig
RPMs for Fedora will be available "soon"
Laine
[1] To verify the signature, first download both the .sig file and the
corresponding tarball. Then, run a command like this:
gpg --verify netcf-0.1.8.tar.gz.sig
If that command fails because you don't have the required public key,
then run this command to import it:
gpg --keyserver keys.gnupg.net --recv-keys 62D11E4C
and rerun the `gpg --verify' command.
12 years, 10 months