Re: [netcf-devel] [libvirt-users] [netcf]IFF_RUNNING flag on a bridge device
by Laine Stump
On 05/27/2014 09:07 AM, Jianwei Hu wrote:
> Hi All,
>
> I have one netcf question, please help me to resolve it, thanks.
>
> I can set a IFF_RUNNING flag to a bridge device which are no interface device attached. What status of a flag on a bridge device in current kernel?(w/o interface), is this a new change in kernel or other component? In netcf, but there is a patch to fix that flag issue, I can't understand it.
>
> fix wrong status of bridge devices
> The IFF_RUNNING flag is not set on a bridge device if there are no devices attached to it. So bridges without attached devices are reported as inactive. Destroying inactive devices leads to an error and thus the device can't be removed (easily) from the operating system. This patch checks if the device is a bridge and if so ignores the IFF_RUNNING flag.
Well, I took the patch submitter (Hendrik Schwartke <hendrik(a)os-t.de>)
at his word about the brokenness, and the patch didn't *hurt* anything,
so I pushed it. But now that I try it out I see that, at least on the
kernel version in Fedora 20 (and RHEL6.6) IFF_RUNNING *is* set when a
bridge device is ifconfiged up.
So I'm not sure what had caused the original problem, maybe Hendrik can
eluminate us on that, but it makes sense (since the whole reason for
adding the check of IFF_RUNNING in the first place was to notice when an
ethernet is unplugged, but a bridge is *never* plugged or unplugged in
the sense that we're looking for) and doesn't harm anything (and
apparently does fix something for Hendrik).
BTW, when you have netcf-specific questions of patches, you can send
them to netcf-devel(a)lists.fedorahosted.org
9 years, 9 months
Persistent_net_rules augeas lens
by Lorenzo M. Catucci
As requested by Daniel P. Berrange, I'm forwarding to the netcf-devel
list the the request I've first sent directly to both Daniel and
Patrick Mullaney.
I'd like to propose integrating the lens into augeas proper, just as
it stands in netcf's git sources.
While I understand there should be no problem (at least with the
spirit of) the license[1], I'd like to avoid an action which could
upset anyone of the original stakeholders, and would therefore be
grateful if you could let me know if you agree with such a proposal.
As a matter of facts, I'd like to send a pull request for the commits at
https://github.com/lmctv/augeas/compare/persistent_net_rules
As you can see, I've just added a test file, which I've wired to
augeas' test harness, and changed the comment in the lens by inserting
a reference to the original authors and an explicit license line.
Thank you very much, yours
lorenzo
[1] Really, augeas proper is LGPL v2+ licensed, while I think
persistent_net_rules is inheriting netcf's LGPL v2.1 license;
therefore I think there must be an explicit licence change endorsement
from Daniel and Patrick.
9 years, 10 months
release of netcf-0.2.4
by Laine Stump
I've just released netcf-0.2.4. It mostly contains some bugfixes that have built up. Highlights:
- wait for IFF_UP and IFF_RUNNING after calling ifup (Laine Stump)
- don't require IFF_RUNNING for bridge devices (Hendrik Schwartke)
- avoid memory leak in debian when listing interfaces (Eric Blake)
- avoid use of uninitialized data when getting mac address (Laine Stump)
(fixes https://bugzilla.redhat.com/show_bug.cgi?id=1046594 )
- limit interface names to IFNAMSIZ-1 characters in length (Jincheng Miao)
- support systemd for netcf-transaction (Laine Stump)
- transform STP value from "yes/no" to "on/off" (Martin Wilck)
- remove extraneous quotes from BONDING_OPTS (Satoru SATOH)
(fixes https://bugzilla.redhat.com/show_bug.cgi?id=798851 )
( https://bugzilla.redhat.com/show_bug.cgi?id=879055 )
- fix configure time check for opensuse (Ting Liu)
- various automake and gnulib updates/fixes (Eric Blake)
Thanks to everyone for their contributions!
The tarball is available in the usual place:
Tarball: https://fedorahosted.org/released/netcf/netcf-0.2.4.tar.gz
GPG signature[1]: https://fedorahosted.org/released/netcf/netcf-0.2.4.tar.gz.sig
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.2.4.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.
9 years, 10 months
[PATCH] Avoid to define a IF which's name exceeds the maximum length.
by jmiao
drv_define() doesn't check the length of IF's name, so the IF's name
may be trancated to maxium length(IFNAMSIZ - 1).
Signed-off-by: jmiao <jmiao(a)redhat.com>
---
AUTHORS | 3 ++-
src/drv_debian.c | 3 +++
src/drv_redhat.c | 3 +++
src/drv_suse.c | 3 +++
4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/AUTHORS b/AUTHORS
index 6188570..bee6abe 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -21,4 +21,5 @@ Contributions by:
Hendrik Schwartke <hendrik(a)os-t.de>
Ting Liu <b28495(a)freescale.com>
Satoru SATOH <ssato(a)redhat.com>
- Martin Wilck <martin.wilck(a)ts.fujitsu.com>
\ No newline at end of file
+ Martin Wilck <martin.wilck(a)ts.fujitsu.com>
+ Jincheng Miao <jmiao(a)redhat.com>
diff --git a/src/drv_debian.c b/src/drv_debian.c
index def0c0e..342777c 100644
--- a/src/drv_debian.c
+++ b/src/drv_debian.c
@@ -925,6 +925,9 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
name = device_name_from_xml(ncf, ncf_xml);
ERR_COND_BAIL(name == NULL, ncf, EINTERNAL);
+ ERR_THROW(strlen(name) >= IFNAMSIZ, ncf, EINTERNAL,
+ "The interface name '%s' exceeds the maximum length: %d",
+ name, IFNAMSIZ - 1);
rm_all_interfaces(ncf, ncf_xml);
ERR_BAIL(ncf);
diff --git a/src/drv_redhat.c b/src/drv_redhat.c
index 3697473..c40d7fb 100644
--- a/src/drv_redhat.c
+++ b/src/drv_redhat.c
@@ -878,6 +878,9 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
name = device_name_from_xml(ncf, ncf_xml);
ERR_COND_BAIL(name == NULL, ncf, EINTERNAL);
+ ERR_THROW(strlen(name) >= IFNAMSIZ, ncf, EINTERNAL,
+ "The interface name '%s' exceeds the maximum length: %d",
+ name, IFNAMSIZ - 1);
rm_all_interfaces(ncf, ncf_xml);
ERR_BAIL(ncf);
diff --git a/src/drv_suse.c b/src/drv_suse.c
index 666d802..782d366 100644
--- a/src/drv_suse.c
+++ b/src/drv_suse.c
@@ -1020,6 +1020,9 @@ struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
name = device_name_from_xml(ncf, ncf_xml);
ERR_COND_BAIL(name == NULL, ncf, EINTERNAL);
+ ERR_THROW(strlen(name) >= IFNAMSIZ, ncf, EINTERNAL,
+ "The interface name '%s' exceeds the maximum length: %d",
+ name, IFNAMSIZ - 1);
rm_all_interfaces(ncf, ncf_xml);
ERR_BAIL(ncf);
--
1.8.2.1
9 years, 10 months
[PATCH] fix wrong status of bridge devices
by Hendrik Schwartke
The IFF_RUNNING flag is not set on a bridge device if there are no
devices attached to it. So bridges without attached devices are reported
as inactive. Destroying inactive devices leads to an error and thus the
device can't be removed (easily) from the operating system.
This patch checks if the device is a bridge and if so ignores the IFF_RUNNING
flag.
---
src/dutil_linux.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index 7af741e..2db166a 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -456,6 +456,15 @@ void modprobed_unalias_bond(struct netcf *ncf, const char *name) {
int if_is_active(struct netcf *ncf, const char *intf) {
struct ifreq ifr;
+ short flags_to_check = IFF_UP;
+
+ /*
+ * IFF_RUNNING is set on a bridge only if there is at least one
+ * network device attached.
+ */
+ if(if_type(ncf, intf) != NETCF_IFACE_TYPE_BRIDGE) {
+ flags_to_check |= IFF_RUNNING;
+ }
MEMZERO(&ifr, 1);
strncpy(ifr.ifr_name, intf, sizeof(ifr.ifr_name));
@@ -463,7 +472,7 @@ int if_is_active(struct netcf *ncf, const char *intf) {
if (ioctl(ncf->driver->ioctl_fd, SIOCGIFFLAGS, &ifr)) {
return 0;
}
- return ((ifr.ifr_flags & (IFF_UP|IFF_RUNNING)) == (IFF_UP|IFF_RUNNING));
+ return ((ifr.ifr_flags & flags_to_check) == flags_to_check);
}
netcf_if_type_t if_type(struct netcf *ncf, const char *intf) {
--
1.9.1
9 years, 10 months