[PATCH] Avoid pushing extraneous local-only tags when uploading a release
by Laine Stump
---
Makefile.maint | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 7fc4943..a7de448 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -33,7 +33,7 @@ upload:
@gpg -q --batch --verify $(tarball).sig > /dev/null 2>&1 || \
gpg --output $(tarball).sig --detach-sig $(tarball); \
scp $(tarball) $(tarball).sig $(rel_dir); \
- git push --tags
+ git push origin tag release-$(VERSION)
tag-release:
@git tag -s release-$(VERSION)
--
1.7.2.3
13 years, 6 months
ANNOUNCE: netcf-0.1.7
by Laine Stump
I'm happy to finally announce the release of netcf 0.1.7.
Here's a list of the changes in this release:
* Remove code that modifies iptables config for bridges - this
was the cause of numerous bug reports against RHEL, and
after discussion we decided it was also outside the scope
of what netcf should be doing anyway. (Laine Stump)
* Register gnulib as a proper submodule - this will assure that
any future build done based on a tag will use exactly the same
gnulib sources as a build done at any other time based on the
same tag. (Laine Stump)
* Fix bootstrap to work with newer libtools (Eric Blake)
* Don't delete physical interface config when defining a vlan.
(Laine Stump/David Lutterkort)
* Properly handle quoted entries in sysconfig files - this was causing
problems
in recent releases of Fedora and RHEL, which are creating interfaces
with the device name in quotes. (David Lutterkort)
* Make miimon/arpmon optional when defining a bond interface.
(Cole Robinson)
* Only build datadir.h after configure is run (to allow doing "make && sudo
make install" when builddir is on root-squashing NFS). (Cole Robinson)
Tarball: https://fedorahosted.org/released/netcf/netcf-0.1.7.tar.gz
GPG signature[1]:
https://fedorahosted.org/released/netcf/netcf-0.1.7.tar.gz.sig
RPMs for Fedora will be available as soon as I've figured out the new
Fedora package build system :-)
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.5.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.
13 years, 6 months
[PATCH 1/5] Windows port of netcf api calls
by Adam Stokes
---
mingw32-netcf.spec.in | 67 +++++++++
netcf-wininst.nsi | 37 +++++
src/netcf_win.c | 358 +++++++++++++++++++++++++++++++++++++++++++++++++
src/netcf_win.h | 70 ++++++++++
4 files changed, 532 insertions(+), 0 deletions(-)
create mode 100644 mingw32-netcf.spec.in
create mode 100755 netcf-wininst.nsi
create mode 100644 src/netcf_win.c
create mode 100644 src/netcf_win.h
diff --git a/mingw32-netcf.spec.in b/mingw32-netcf.spec.in
new file mode 100644
index 0000000..fe0e073
--- /dev/null
+++ b/mingw32-netcf.spec.in
@@ -0,0 +1,67 @@
+%global __strip %{_mingw32_strip}
+%global __objdump %{_mingw32_objdump}
+%global _use_internal_dependency_generator 0
+%global __find_requires %{_mingw32_findrequires}
+%global __find_provides %{_mingw32_findprovides}
+%define __debug_install_post %{_mingw32_debug_install_post}
+
+Name: mingw32-netcf
+Version: @VERSION@
+Release: 1%{?dist}%{?extra_release}
+Summary: Cross-platform network configuration library
+
+Group: System Environment/Libraries
+License: LGPLv2+
+URL: https://fedorahosted.org/netcf/
+Source0: http://astokes.fedorapeople.org/%{name}/%{name}-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires: mingw32-filesystem >= 56
+BuildRequires: mingw32-readline
+BuildRequires: mingw32-binutils
+BuildRequires: mingw32-libxml2
+BuildRequires: mingw32-libxslt
+BuildRequires: mingw32-gcc
+BuildRequires: mingw32-gettext
+BuildRequires: mingw32-w32api
+Requires: pkgconfig
+
+%description
+A library for modifying the network configuration of a system. Network
+configurations are expresed in a platform-independent XML format, which
+netcf translates into changes to the system's 'native' network
+configuration files.
+
+MinGW cross-compiled Windows library.
+
+%prep
+%setup -q
+
+%build
+PATH=%{_mingw32_bindir}:$PATH \
+%{_mingw32_configure} --disable-static
+make %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p"
+rm -rf $RPM_BUILD_ROOT%{_mingw32_datadir}/netcf
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%{_mingw32_bindir}/ncftool.exe
+%{_mingw32_bindir}/libnetcf-1.dll
+%{_mingw32_includedir}/*.h
+%{_mingw32_libdir}/pkgconfig/netcf.pc
+%{_mingw32_libdir}/libnetcf.dll.a
+%{_mingw32_libdir}/libnetcf.la
+%{_mingw32_datadir}
+
+%doc AUTHORS COPYING NEWS
+
+%changelog
+* Mon Sep 1 2010 Adam Stokes <ajs(a)redhat.com> - 0.1.6-1
+- MinGW Port
diff --git a/netcf-wininst.nsi b/netcf-wininst.nsi
new file mode 100755
index 0000000..d0d1687
--- /dev/null
+++ b/netcf-wininst.nsi
@@ -0,0 +1,37 @@
+; netcf-wininst.nsi
+; prompt for dir; copy files
+;--------------------------------
+
+; The name of the installer
+Name "netcf installer"
+
+; The file to write
+OutFile "netcf-setup.exe"
+
+; The default installation directory
+InstallDir $PROGRAMFILES\netcf
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+;--------------------------------
+
+; Pages
+
+Page directory
+Page instfiles
+
+;--------------------------------
+
+; The stuff to install
+Section "" ;No components page, name is not important
+
+ ; Set output path to the installation directory.
+ SetOutPath $INSTDIR
+
+ ; Put file there
+ File src/.libs/libnetcf-1.dll
+ File src/.libs/ncftool.exe
+ File /usr/i686-pc-mingw32/sys-root/mingw/bin/*.dll
+
+SectionEnd ; end the section
diff --git a/src/netcf_win.c b/src/netcf_win.c
new file mode 100644
index 0000000..f0a9818
--- /dev/null
+++ b/src/netcf_win.c
@@ -0,0 +1,358 @@
+#include <config.h>
+#include <internal.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "netcf_win.h"
+
+#define ADDR_BLOCK 5
+#define GAA_FLAGS ( GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_MULTICAST )
+#define BUFSIZE 1024
+
+PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable) {
+ DWORD r = 0;
+ DWORD buf = 0;
+
+ ipAddrTable = (PMIB_IPADDRTABLE) malloc(sizeof (MIB_IPADDRTABLE));
+ if (GetIpAddrTable(ipAddrTable, &buf, 0) == ERROR_INSUFFICIENT_BUFFER) {
+ free(ipAddrTable);
+ ipAddrTable = (PMIB_IPADDRTABLE) malloc(buf);
+ if (ipAddrTable == NULL)
+ goto error;
+ }
+
+ if((r = GetIpAddrTable(ipAddrTable, &buf, 0)) == NO_ERROR)
+ return ipAddrTable;
+
+ error:
+ free(ipAddrTable);
+ return ipAddrTable;
+}
+
+PMIB_IFTABLE _get_if_table(PMIB_IFTABLE intfTable) {
+ DWORD bufferLength = 0;
+ DWORD r = 0;
+ intfTable = (PMIB_IFTABLE) malloc(sizeof(MIB_IFTABLE));
+ if (intfTable == NULL)
+ goto error;
+
+ bufferLength = sizeof(MIB_IFTABLE);
+ if (GetIfTable(intfTable, &bufferLength, FALSE) == ERROR_INSUFFICIENT_BUFFER) {
+ free(intfTable);
+ intfTable = (PMIB_IFTABLE) malloc(bufferLength);
+ if (intfTable == NULL)
+ goto error;
+ }
+
+ if ((r = GetIfTable(intfTable, &bufferLength, FALSE)) == NO_ERROR)
+ return intfTable;
+ error:
+ free(intfTable);
+}
+
+PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES addrList) {
+ ULONG bufferLength = 0;
+ DWORD r;
+ int i;
+
+ for(i = 0; i < ADDR_BLOCK; i++) {
+ r = GetAdaptersAddresses(AF_INET, GAA_FLAGS, NULL, addrList, &bufferLength);
+ if (r != ERROR_BUFFER_OVERFLOW) {
+ break;
+ }
+ if (addrList != NULL) {
+ goto error;
+ }
+ addrList = (PIP_ADAPTER_ADDRESSES) malloc(bufferLength);
+ if (addrList == NULL)
+ goto error;
+ }
+ return addrList;
+ error:
+ free(addrList);
+}
+
+/* Create a new netcf if instance for interface NAME */
+struct netcf_if *make_netcf_if(struct netcf *ncf, char *name) {
+ int r;
+ struct netcf_if *result = NULL;
+
+ r = make_ref(result);
+ ERR_NOMEM(r < 0, ncf);
+ result->ncf = ref(ncf);
+ result->name = name;
+ return result;
+
+ error:
+ unref(result, netcf_if);
+ return result;
+}
+
+static int list_interface_ids(struct netcf *ncf ATTRIBUTE_UNUSED,
+ int maxnames ATTRIBUTE_UNUSED,
+ char **names, unsigned int flags ATTRIBUTE_UNUSED,
+ const char *id_attr ATTRIBUTE_UNUSED) {
+ unsigned int nint = 0;
+
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ adapterp = _get_ip_adapter_info(addrList);
+ for (nint = 0; adapterp != NULL; nint++) {
+ if (names) {
+ char name[BUFSIZE];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, name, sizeof(name), NULL, NULL);
+ names[nint] = strdup(name);
+ }
+ adapterp = adapterp->Next;
+ }
+ return nint;
+ error:
+ free(addrList);
+ return -1;
+}
+
+int drv_list_interfaces(struct netcf *ncf,
+ int maxnames ATTRIBUTE_UNUSED, char **names,
+ unsigned int flags ATTRIBUTE_UNUSED) {
+ return list_interface_ids(ncf, 0, names, 0, NULL);
+}
+
+
+int drv_num_of_interfaces(struct netcf *ncf, unsigned int flags ATTRIBUTE_UNUSED) {
+ return list_interface_ids(ncf, 0, NULL, 0, NULL);
+}
+
+
+struct netcf_if *drv_lookup_by_name(struct netcf *ncf, const char *name) {
+ struct netcf_if *nif = NULL;
+ char *name_dup;
+ unsigned int nint = 0;
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ adapterp = _get_ip_adapter_info(addrList);
+ for (nint = 0; adapterp != NULL; nint++) {
+ if (name) {
+ char wName[BUFSIZE];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName, name) == 0) {
+ name_dup = strdup(wName);
+ nif = make_netcf_if(ncf, name_dup);
+ goto done;
+ }
+ }
+ adapterp = adapterp->Next;
+ }
+
+ done:
+ return nif;
+}
+
+
+const char *drv_mac_string(struct netcf_if *nif) {
+ // struct netcf *ncf = nif->ncf;
+
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ adapterp = _get_ip_adapter_info(addrList);
+ while(adapterp != NULL) {
+ char wName[BUFSIZE];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ if ((int)adapterp->PhysicalAddressLength >= 6)
+ continue; /* just want ethernet for now */
+ nif->mac = asprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X",
+ adapterp->PhysicalAddress[0],
+ adapterp->PhysicalAddress[1],
+ adapterp->PhysicalAddress[2],
+ adapterp->PhysicalAddress[3],
+ adapterp->PhysicalAddress[4],
+ adapterp->PhysicalAddress[5]);
+ goto done;
+ }
+ adapterp = adapterp->Next;
+ }
+ done:
+ return nif->mac;
+}
+
+int drv_if_down(struct netcf_if *nif) {
+ PMIB_IFTABLE intfTable = NULL;
+ PMIB_IFTABLE intfTableDup = NULL;
+ PMIB_IFROW intRow;
+ int i;
+
+ intfTableDup = _get_if_table(intfTable);
+ if (intfTableDup != NULL) {
+ for (i = 0; i < (int) intfTableDup->dwNumEntries; i++) {
+ intRow = (PMIB_IFROW) & intfTableDup->table[i];
+ char wName[BUFSIZE];
+ WideCharToMultiByte(CP_UTF8, 0, intRow->wszName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ intRow->dwAdminStatus = MIB_IF_ADMIN_STATUS_DOWN;
+ if (SetIfEntry(intRow) == NO_ERROR)
+ goto done;
+ }
+ }
+ /* Unable to shutdown interface */
+ return -1;
+ }
+ done:
+ return 0;
+}
+
+int drv_if_up(struct netcf_if *nif) {
+ PMIB_IFTABLE intfTable = NULL;
+ PMIB_IFTABLE intfTableDup = NULL;
+ PMIB_IFROW intRow;
+ int i;
+
+ intfTableDup = _get_if_table(intfTable);
+ if (intfTableDup != NULL) {
+ for (i = 0; i < (int) intfTableDup->dwNumEntries; i++) {
+ intRow = (PMIB_IFROW) & intfTableDup->table[i];
+ char wName[BUFSIZE];
+ WideCharToMultiByte(CP_UTF8, 0, intRow->wszName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ intRow->dwAdminStatus = MIB_IF_ADMIN_STATUS_UP;
+ if (SetIfEntry(intRow) == NO_ERROR)
+ goto done;
+ }
+ }
+ /* Unable to shutdown interface */
+ return -1;
+ }
+ done:
+ return 0;
+}
+
+int drv_if_ipaddresses(struct netcf_if *nif, char *ipBuf) {
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ PMIB_IPADDRTABLE ipAddrTable = NULL;
+ PMIB_IPADDRTABLE ipAddrTableDup = NULL;
+ IN_ADDR ipAddr;
+ DWORD r = 0;
+ int i;
+
+ if ((ipAddrTableDup = _get_ip_addr_table(ipAddrTable)) == NULL)
+ return -1;
+
+ adapterp = _get_ip_adapter_info(addrList);
+ if (adapterp != NULL) {
+ while(adapterp) {
+ if (adapterp->OperStatus != 1)
+ continue;
+
+ /* pull ip addresses from interface */
+ for (i = 0; i<ipAddrTableDup->dwNumEntries; i++) {
+ if (ipAddrTableDup->table[i].dwIndex == adapterp->IfIndex) {
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ ipAddr.S_un.S_addr = (unsigned long) ipAddrTableDup->table[i].dwAddr;
+ sprintf(ipBuf,"%d",inet_ntoa(ipAddr));
+ return 0;
+ }
+ }
+ }
+ adapterp = adapterp->Next;
+ }
+
+ }
+ free(ipAddrTable);
+ free(addrList);
+ return -1;
+}
+
+int drv_add_ip_address(struct netcf_if *nif, char *ipAddr, char *netmask) {
+ IN_ADDR addr;
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ PMIB_IPADDRTABLE ipAddrTable = NULL;
+ PMIB_IPADDRTABLE ipAddrTableDup = NULL;
+ ULONG bufferLength = 0;
+ DWORD r;
+ DWORD ifIndex;
+ int i;
+
+ /* ipv4 addr/subnetmask */
+ UINT IPAddress;
+ UINT IPNetMask;
+
+ /* handles to IP returned */
+ ULONG NTEContext = 0;
+ ULONG NTEInstance = 0;
+
+ if ((IPAddress = inet_addr(ipAddr)) == INADDR_NONE)
+ return -1;
+
+ if ((IPNetMask = inet_addr(netmask)) == INADDR_NONE)
+ return -1;
+
+
+ ipAddrTableDup = _get_ip_addr_table(ipAddrTable);
+ if (ipAddrTableDup != NULL) {
+ for(i=0;i<ipAddrTableDup->dwNumEntries;i++) {
+ ifIndex = ipAddrTableDup->table[i].dwIndex;
+ char wName[BUFSIZE];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ if ((r = AddIPAddress(IPAddress, IPNetMask, ifIndex,
+ &NTEContext, &NTEInstance)) == NO_ERROR) {
+ return 0;
+ }
+ }
+ }
+ }
+ free(ipAddrTable);
+ return -1;
+}
+
+
+/* needs further testing
+int drv_rm_ip_address(struct netcf_if *nif, ULONG NTEContext) {
+ DWORD r = 0;
+ if ((r = DeleteIpAddress(NTEConext)) == NO_ERROR)
+ return 0;
+ return -1;
+}
+*/
+
+int drv_list_dns_server(struct netcf_if *nif, char *ip_str) {
+ char bufferLength[1024];
+ IP4_ARRAY *ips = (IP4_ARRAY*) bufferLength;
+ DWORD len = sizeof(bufferLength);
+ DNS_STATUS status;
+
+ status = DnsQueryConfig(DnsConfigDnsServerList, FALSE,
+ NULL, NULL, ips, &len);
+ if (status == 0) {
+ DWORD i;
+ for (i = 0; i < ips->AddrCount; i++) {
+ DWORD ip = ips->AddrArray[i];
+ snprintf(ip_str, sizeof(ip_str),
+ "%d.%d.%d.%d", (ip >> 0) & 255, (ip >> 8) & 255,
+ (ip >> 16) & 255, (ip >> 24) & 255);
+ }
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
+/* NOT IMPLEMENTED
+int drv_add_dns_server(struct netcf_if *nif, const char *dnsAddr) {
+ return -1;
+}
+
+int drv_rm_dns_server(struct netcf_if *nif) {
+ return -1;
+}
+*/
diff --git a/src/netcf_win.h b/src/netcf_win.h
new file mode 100644
index 0000000..1b88772
--- /dev/null
+++ b/src/netcf_win.h
@@ -0,0 +1,70 @@
+/*
+ * netcf-win.h: windows functions
+ *
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Adam Stokes <ajs(a)redhat.com>
+ */
+
+#ifndef NETCF_WIN_H
+#define NETCF_WIN_H
+
+#ifndef WINVER
+#define WINVER 0x0501
+#endif
+
+#include <config.h>
+#include "internal.h"
+
+#include <stdbool.h>
+#include <string.h>
+#include <windows.h>
+#include <winsock.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <iphlpapi.h>
+#include <windns.h>
+#include "safe-alloc.h"
+#include "ref.h"
+#include "list.h"
+
+struct netcf_if *make_netcf_if(struct netcf *ncf, char *name);
+
+/* structure return of interface table */
+PMIB_IFTABLE _get_if_table(PMIB_IFTABLE intfTable);
+
+/* structure return of adapter info */
+PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES addrList);
+
+PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable);
+
+/* Reports ip addresses */
+int drv_if_ipaddresses(struct netcf_if *nif, char *ipBuf);
+
+/* add ip address to device */
+int drv_add_ip_address(struct netcf_if *nif, char *ipAddr,
+ char *netmask);
+/* remove ip address from device */
+int drv_rm_ip_address(struct netcf_if *nif, ULONG NTEContext);
+/* add dns server to device */
+int drv_add_dns_server(struct netcf_if *nif, ULONG NTEContext);
+/* rm dns server from device */
+int drv_rm_dns_server(struct netcf_if *nif);
+/* list dns server */
+int drv_list_dns_server(struct netcf_if *ncf, char *ip_str);
+
+#endif /* NETCF_WIN_H */
--
1.7.2.3
13 years, 6 months
[PATCH 0/2] Remove code that modifies iptables config for bridges
by Laine Stump
After having several bug reports of various netcf initialization
failures related to this code, and an IRC discussion of the
appropriateness of automatically tweaking firewall policy when
examining interface configuration, we decided it was best to eliminate
the code in netcf that modifies the iptables config to add this rule:
-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
(see PATCH 2/2 for detailed reasons).
Note that, even with this code removed, there is still one other
related problem - if there are no bridges defined on the system at
boot time (in /etc/sysconfig/network-scripts/ifcfg-*), the setting of
net.bridge.bridge-nf-call-iptablesin sysctl.conf will not take effect,
leaving the bridge module default setting of "1" in place. The result
will be that (since the aforementioned iptables rule won't be added)
that traffic will not pass on any newly defined bridges until 1) the
network service is restarted (or some other procedure that causes
"sysctl -a -p" to be run), or 2) the system is rebooted. Fixing that
is beyond the scope of netcf, though.
13 years, 6 months
[PATCH] remove duplicate routines
by Adam Stokes
---
src/netcf_win.c | 14 +-------------
src/netcf_win.h | 2 --
2 files changed, 1 insertions(+), 15 deletions(-)
diff --git a/src/netcf_win.c b/src/netcf_win.c
index 166465e..e443614 100644
--- a/src/netcf_win.c
+++ b/src/netcf_win.c
@@ -13,7 +13,7 @@ PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable) {
DWORD r = 0;
DWORD buf = 0;
- ipAddrTable = (PMIB_IPADDRTABLE) sizeof (MIB_IPADDRTABLE);
+ ipAddrTable = (PMIB_IPADDRTABLE) malloc(sizeof (MIB_IPADDRTABLE));
if (GetIpAddrTable(ipAddrTable, &buf, 0) == ERROR_INSUFFICIENT_BUFFER) {
free(ipAddrTable);
ipAddrTable = (PMIB_IPADDRTABLE) malloc(buf);
@@ -215,18 +215,6 @@ void drv_close(struct netcf *ncf) {
#endif
}
-int xasprintf(char **strp, const char *format, ...) {
- va_list args;
- int result;
-
- va_start (args, format);
- result = vasprintf (strp, format, args);
- va_end (args);
- if (result < 0)
- *strp = NULL;
- return result;
-}
-
/* Create a new netcf if instance for interface NAME */
struct netcf_if *make_netcf_if(struct netcf *ncf, char *name) {
int r;
diff --git a/src/netcf_win.h b/src/netcf_win.h
index 845082a..1b88772 100644
--- a/src/netcf_win.h
+++ b/src/netcf_win.h
@@ -42,9 +42,7 @@
#include "ref.h"
#include "list.h"
-
struct netcf_if *make_netcf_if(struct netcf *ncf, char *name);
-int xasprintf(char **strp, const char *format, ...);
/* structure return of interface table */
PMIB_IFTABLE _get_if_table(PMIB_IFTABLE intfTable);
--
1.7.2.3
13 years, 6 months
[PATCH 1/2] Making changes based on suggestions from Eric Blake
by Adam Stokes
https://fedorahosted.org/pipermail/netcf-devel/2010-September/000449.html
---
autogen.sh | 2 +-
bootstrap | 29 ++++++++--------
configure.ac | 9 +----
mingw32-netcf.spec.in | 14 +++----
src/Makefile.am | 6 +--
src/netcf.c | 39 ++++++++++++++++++++++
src/netcf_win.c | 86 ++++++++++---------------------------------------
src/netcf_win.h | 25 +-------------
8 files changed, 83 insertions(+), 127 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index 156c5fa..b0197c3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -85,7 +85,7 @@ fi
mkdir -p $BUILD_AUX
$LIBTOOLIZE --copy --force
-./bootstrap $GNULIB_SRCDIR
+./bootstrap ${GNULIB_SRCDIR:+--gnulib-srcdir="$GNULIB_SRCDIR"}
aclocal -I gnulib/m4
autoheader
automake --add-missing
diff --git a/bootstrap b/bootstrap
index 57ed2df..84d81cb 100755
--- a/bootstrap
+++ b/bootstrap
@@ -58,28 +58,28 @@ gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit
modules='
+arpa_inet
c-ctype
+close
+fcntl
+getdtablesize
+getopt-posix
+inet_ntop
+inet_pton
+netinet_in
+pthread
read-file
safe-alloc
-warnings
-sys_wait
sigaction
-pthread
-unistd
-getdtablesize
signal
-arpa_inet
-sys_ioctl
-getopt-posix
+socket
string
+sys_ioctl
sys_socket
-socket
-netinet_in
+sys_wait
+unistd
vasprintf
-fcntl
-inet_ntop
-inet_pton
-close
+warnings
'
# Tell gnulib to:
@@ -94,4 +94,5 @@ $gnulib_tool \
--tests-base=gnulib/tests \
--aux-dir=build/aux \
--quiet \
+ --libtool \
--import $modules
diff --git a/configure.ac b/configure.ac
index cba128b..c1e000d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,7 @@
AC_INIT(netcf, 0.1.6)
AC_CONFIG_SRCDIR([src/netcf.c])
AC_CONFIG_AUX_DIR([build/aux])
+AC_CONFIG_MACRO_DIR([gnulib/m4])
AM_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([-Wno-portability 1.11 color-tests parallel-tests])
AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
@@ -25,14 +26,6 @@ PLATFORM_WIN32="no"
case "$host" in
*-*-mingw*)
PLATFORM_WIN32="yes"
- MINGW_EXTRA_LDFLAGS="-no-undefined"
- ;;
- *-*-cygwin*)
- MINGW_EXTRA_LDFLAGS="-no-undefined"
- ;;
- *-*-linux*)
- MINGW_EXTRA_LDFLAGS="-no-undefined"
- ;;
*)
;;
esac
diff --git a/mingw32-netcf.spec.in b/mingw32-netcf.spec.in
index bdae12b..489dafb 100644
--- a/mingw32-netcf.spec.in
+++ b/mingw32-netcf.spec.in
@@ -3,6 +3,7 @@
%global _use_internal_dependency_generator 0
%global __find_requires %{_mingw32_findrequires}
%global __find_provides %{_mingw32_findprovides}
+%define __debug_install_post %{_mingw32_debug_install_post}
Name: mingw32-netcf
Version: @VERSION@
@@ -53,20 +54,17 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,-)
%{_mingw32_bindir}/ncftool.exe
%{_mingw32_bindir}/libnetcf-1.dll
+%{_mingw32_includedir}/*.h
%{_mingw32_libdir}/pkgconfig/netcf.pc
-%{_mingw32_libdir}/libnetcf-1.dll.a
-%{_mingw32_libdir}/libnetcf-1.la
+%{_mingw32_libdir}/libnetcf.dll.a
+%{_mingw32_libdir}/libnetcf.la
%{_mingw32_datadir}
%doc AUTHORS COPYING NEWS
%changelog
-* Mon Sep 1 2010 Adam Stokes <ajs(a)redhat.com> - 0.1.6-2
-- Update spec to not require .dll.a or *.la
-- Fixed building of DLL
-
-* Thu Apr 16 2010 Laine Stump <laine(a)redhat.com> - 0.1.6-1
-- New version
+* Mon Sep 1 2010 Adam Stokes <ajs(a)redhat.com> - 0.1.6-1
+- MinGW Port
* Mon Nov 30 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.5-1
- New version
diff --git a/src/Makefile.am b/src/Makefile.am
index 16f8f1e..98025cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@ GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
AM_CFLAGS = $(NETCF_CFLAGS) $(GNULIB_CFLAGS) $(WARN_CFLAGS) \
$(LIBXML_CFLAGS) $(LIBXSLT_CFLAGS) $(LIBAUGEAS_CFLAGS)
-include_HEADERS = netcf.h
+include_HEADERS = netcf.h netcf_win.h
lib_LTLIBRARIES = libnetcf.la
@@ -32,14 +32,12 @@ libnetcf_la_SOURCES = netcf.h netcf.c internal.h \
ref.h list.h \
xslt_ext.c $(DRIVER_SOURCES)
libnetcf_la_LDFLAGS = -Wl,--version-script=netcf.syms \
- -version-info $(LIBNETCF_VERSION_INFO) @MINGW_EXTRA_LDFLAGS@
+ -version-info $(LIBNETCF_VERSION_INFO) -no-undefined
libnetcf_la_LIBADD = $(NETCF_LIBDEPS) $(GNULIB)
if PLATFORM_WIN32
libnetcf_la_LIBADD += $(WIN32LIB)
endif
-#libnetcf_la_DEPENDENCIES = $(libnetcf_la_LIBADD) netcf.syms
-
ncftool_SOURCES = ncftool.c
ncftool_LDADD = libnetcf.la $(READLINE_LIBS) $(GNULIB)
diff --git a/src/netcf.c b/src/netcf.c
index f43d1c2..7948d0b 100644
--- a/src/netcf.c
+++ b/src/netcf.c
@@ -109,7 +109,12 @@ int ncf_init(struct netcf **ncf, const char *root) {
if ((*ncf)->data_dir == NULL)
(*ncf)->data_dir = NETCF_DATADIR "/netcf";
(*ncf)->debug = getenv("NETCF_DEBUG") != NULL;
+#ifdef WIN32
+ return 0;
+#else
+ /* Needs investigation on WIN32 */
return drv_init(*ncf);
+#endif
oom:
ncf_close(*ncf);
*ncf = NULL;
@@ -159,12 +164,16 @@ struct netcf_if * ncf_lookup_by_name(struct netcf *ncf, const char *name) {
return drv_lookup_by_name(ncf, name);
}
+#ifdef WIN32
+int ncf_lookup_by_mac_string() { return -1; }
+#else
int
ncf_lookup_by_mac_string(struct netcf *ncf, const char *mac,
int maxifaces, struct netcf_if **ifaces) {
API_ENTRY(ncf);
return drv_lookup_by_mac_string(ncf, mac, maxifaces, ifaces);
}
+#endif
/*
* Define/start/stop/undefine interfaces
@@ -188,10 +197,15 @@ const char *ncf_if_mac_string(struct netcf_if *nif) {
}
/* Delete the definition */
+#ifdef WIN32
+/* No mingw implementation */
+int ncf_if_undefine() { return -1; };
+#else
int ncf_if_undefine(struct netcf_if *nif) {
API_ENTRY(nif->ncf);
return drv_undefine(nif);
}
+#endif
/* Bring the interface up */
int ncf_if_up(struct netcf_if *nif) {
@@ -210,28 +224,43 @@ int ncf_if_down(struct netcf_if *nif) {
/* Produce an XML description for the interface, in the same format that
* NCF_DEFINE expects
*/
+#ifdef WIN32
+/* No mingw implementation */
+char *ncf_if_xml_desc() { return NULL; }
+#else
char *ncf_if_xml_desc(struct netcf_if *nif) {
API_ENTRY(nif->ncf);
return drv_xml_desc(nif);
}
+#endif
/* Produce an XML description of the current live state of the
* interface, in the same format that NCF_DEFINE expects, but
* potentially with extra info not contained in the static config (ie
* the current IP address of an interface that uses DHCP)
*/
+#ifdef WIN32
+/* No mingw implementation */
+char *ncf_if_xml_state() { return NULL; }
+#else
char *ncf_if_xml_state(struct netcf_if *nif) {
API_ENTRY(nif->ncf);
return drv_xml_state(nif);
}
+#endif
/* Report various status info about the interface as bits in
* "flags". Returns 0 on success, -1 on failure
*/
+#ifdef WIN32
+/* No mingw implementation */
+int ncf_if_status() { return -1; }
+#else
int ncf_if_status(struct netcf_if *nif, unsigned int *flags) {
API_ENTRY(nif->ncf);
return drv_if_status(nif, flags);
}
+#endif
/* Release any resources used by this NETCF_IF; the pointer is invalid
* after this call
@@ -258,17 +287,27 @@ int ncf_error(struct netcf *ncf, const char **errmsg, const char **details) {
/*
* Test interface
*/
+#ifdef WIN32
+/* No mingw implementation */
+int ncf_get_aug() { return -1; }
+#else
int ncf_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml) {
API_ENTRY(ncf);
return drv_get_aug(ncf, ncf_xml, aug_xml);
}
+#endif
+#ifdef WIN32
+/* No mingw implementation */
+int ncf_put_aug() { return -1; }
+#else
int ncf_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
API_ENTRY(ncf);
return drv_put_aug(ncf, aug_xml, ncf_xml);
}
+#endif
#ifndef WIN32
/* Do not see any other way around this as there is no
diff --git a/src/netcf_win.c b/src/netcf_win.c
index a1dbd5c..166465e 100644
--- a/src/netcf_win.c
+++ b/src/netcf_win.c
@@ -5,15 +5,15 @@
#include <stdlib.h>
#include "netcf_win.h"
-#define MAX_TRIES 3
+#define ADDR_BLOCK 5
#define GAA_FLAGS ( GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_MULTICAST )
-#define BUFSIZE 8192
+#define BUFSIZE 1024
PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable) {
DWORD r = 0;
DWORD buf = 0;
- ipAddrTable = (PMIB_IPADDRTABLE) malloc(sizeof (MIB_IPADDRTABLE));
+ ipAddrTable = (PMIB_IPADDRTABLE) sizeof (MIB_IPADDRTABLE);
if (GetIpAddrTable(ipAddrTable, &buf, 0) == ERROR_INSUFFICIENT_BUFFER) {
free(ipAddrTable);
ipAddrTable = (PMIB_IPADDRTABLE) malloc(buf);
@@ -55,7 +55,7 @@ PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES addrList) {
DWORD r;
int i;
- for(i = 0; i < 5; i++) {
+ for(i = 0; i < ADDR_BLOCK; i++) {
r = GetAdaptersAddresses(AF_INET, GAA_FLAGS, NULL, addrList, &bufferLength);
if (r != ERROR_BUFFER_OVERFLOW) {
break;
@@ -72,56 +72,6 @@ PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES addrList) {
free(addrList);
}
-/* All undefined routines in windows */
-int drv_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-int drv_if_status(struct netcf_if *nif, unsigned int *flags) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-int drv_init(struct netcf *ncf) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-int drv_lookup_by_mac_string(struct netcf *ncf, const char *mac,
- int maxifaces, struct netcf_if **ifaces) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-int drv_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-int drv_undefine(struct netcf_if *nif) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-char *drv_xml_desc(struct netcf_if *nif) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
-char *drv_xml_state(struct netcf_if *nif) {
-#ifdef WIN32
- return -1;
-#endif
-}
-
struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
#ifdef WIN32
return ncf;
@@ -304,7 +254,7 @@ static int list_interface_ids(struct netcf *ncf ATTRIBUTE_UNUSED,
adapterp = _get_ip_adapter_info(addrList);
for (nint = 0; adapterp != NULL; nint++) {
if (names) {
- char name[8192];
+ char name[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
-1, name, sizeof(name), NULL, NULL);
names[nint] = strdup(name);
@@ -338,7 +288,7 @@ struct netcf_if *drv_lookup_by_name(struct netcf *ncf, const char *name) {
adapterp = _get_ip_adapter_info(addrList);
for (nint = 0; adapterp != NULL; nint++) {
if (name) {
- char wName[8192];
+ char wName[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
-1, wName, sizeof(wName), NULL, NULL);
if (strcmp(wName, name) == 0) {
@@ -357,26 +307,24 @@ struct netcf_if *drv_lookup_by_name(struct netcf *ncf, const char *name) {
const char *drv_mac_string(struct netcf_if *nif) {
// struct netcf *ncf = nif->ncf;
- char mac[256];
PIP_ADAPTER_ADDRESSES addrList = NULL;
PIP_ADAPTER_ADDRESSES adapterp = NULL;
adapterp = _get_ip_adapter_info(addrList);
while(adapterp != NULL) {
- char wName[8192];
+ char wName[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
-1, wName, sizeof(wName), NULL, NULL);
if (strcmp(wName,nif->name) == 0) {
if ((int)adapterp->PhysicalAddressLength >= 6)
continue; /* just want ethernet for now */
- sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X",
- adapterp->PhysicalAddress[0],
- adapterp->PhysicalAddress[1],
- adapterp->PhysicalAddress[2],
- adapterp->PhysicalAddress[3],
- adapterp->PhysicalAddress[4],
- adapterp->PhysicalAddress[5]);
- nif->mac = strdup(mac);
+ nif->mac = asprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X",
+ adapterp->PhysicalAddress[0],
+ adapterp->PhysicalAddress[1],
+ adapterp->PhysicalAddress[2],
+ adapterp->PhysicalAddress[3],
+ adapterp->PhysicalAddress[4],
+ adapterp->PhysicalAddress[5]);
goto done;
}
adapterp = adapterp->Next;
@@ -395,7 +343,7 @@ int drv_if_down(struct netcf_if *nif) {
if (intfTableDup != NULL) {
for (i = 0; i < (int) intfTableDup->dwNumEntries; i++) {
intRow = (PMIB_IFROW) & intfTableDup->table[i];
- char wName[8192];
+ char wName[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, intRow->wszName,
-1, wName, sizeof(wName), NULL, NULL);
if (strcmp(wName,nif->name) == 0) {
@@ -421,7 +369,7 @@ int drv_if_up(struct netcf_if *nif) {
if (intfTableDup != NULL) {
for (i = 0; i < (int) intfTableDup->dwNumEntries; i++) {
intRow = (PMIB_IFROW) & intfTableDup->table[i];
- char wName[8192];
+ char wName[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, intRow->wszName,
-1, wName, sizeof(wName), NULL, NULL);
if (strcmp(wName,nif->name) == 0) {
@@ -507,7 +455,7 @@ int drv_add_ip_address(struct netcf_if *nif, char *ipAddr, char *netmask) {
if (ipAddrTableDup != NULL) {
for(i=0;i<ipAddrTableDup->dwNumEntries;i++) {
ifIndex = ipAddrTableDup->table[i].dwIndex;
- char wName[8192];
+ char wName[BUFSIZE];
WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
-1, wName, sizeof(wName), NULL, NULL);
if (strcmp(wName,nif->name) == 0) {
diff --git a/src/netcf_win.h b/src/netcf_win.h
index c1bb1d6..845082a 100644
--- a/src/netcf_win.h
+++ b/src/netcf_win.h
@@ -1,7 +1,7 @@
/*
* netcf-win.h: windows functions
*
- * Copyright (C) 2009-2010 Red Hat Inc.
+ * Copyright (C) 2010 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -42,28 +42,7 @@
#include "ref.h"
#include "list.h"
-static int aug_put_xml(struct netcf *ncf, xmlDocPtr xml);
-static int bridge_slaves(struct netcf *ncf, const char *name, char ***slaves);
-static int cmpstrp(const void *p1, const void *p2);
-static int is_slave(struct netcf *ncf, const char *intf);
-static int list_ifcfg_paths(struct netcf *ncf, char ***intf);
-static int list_interface_ids(struct netcf *ncf, int maxnames, char **names,
- unsigned int flags, const char *id_attr);
-static int list_interfaces(struct netcf *ncf, char ***intf);
-static int uniq_ifcfg_paths(struct netcf *ncf, int ndevs, char **devs, char ***intf);
-static bool has_ifcfg_file(struct netcf *ncf, const char *name);
-static bool is_bond(struct netcf *ncf, const char *name);
-static bool is_bridge(struct netcf *ncf, const char *name);
-static char *device_name_from_xml(struct netcf *ncf, xmlDocPtr ncf_xml);
-static char *find_ifcfg_path_by_device(struct netcf *ncf, const char *name);
-static char *find_ifcfg_path_by_hwaddr(struct netcf *ncf, const char *mac);
-static char *find_ifcfg_path(struct netcf *ncf, const char *name);
-static void bond_setup(struct netcf *ncf, const char *name, bool alias);
-static void bridge_physdevs(struct netcf *ncf);
-static void rm_all_interfaces(struct netcf *ncf, xmlDocPtr ncf_xml);
-static void rm_interface(struct netcf *ncf, const char *name);
-static xmlDocPtr aug_get_xml_for_nif(struct netcf_if *nif);
-static xmlDocPtr aug_get_xml(struct netcf *ncf, int nint, char **intf);
+
struct netcf_if *make_netcf_if(struct netcf *ncf, char *name);
int xasprintf(char **strp, const char *format, ...);
--
1.7.2.3
13 years, 6 months
ncftool fails due to bridge-nf-call-iptables turning on when bridge module loads
by Dale Bewley
Regarding:
http://fedorahosted.org/pipermail/netcf-devel/2009-December/000397.html
https://bugzilla.redhat.com/show_bug.cgi?id=536895
which discusses ncftool failing when bridge-nf-call-iptables is turned
on, and how "off" would be a better default state for the bridge module.
This is still a problem on F13.
[root@tofu ~]# rpm -q netcf
netcf-0.1.6-1.fc13.x86_64
[root@tofu ~]# grep bridge-nf-call-iptables /etc/sysctl.conf
net.bridge.bridge-nf-call-iptables = 0
[root@tofu ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables
1
[root@tofu ~]# ncftool list
Failed to initialize netcf
error: unspecified error
[root@tofu ~]# echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables
[root@tofu ~]# ncftool list
eth0
lo
I suppose this is outside the realm of netcf, but perhaps ncftool could
fail with a more helpful error? Not sure if that could also percolate
through netcf-libs to libvirt and virsh.
I have not tested in F14. Has any more thought been given to how to turn
this off by default at the distro level?
13 years, 6 months
Re: [netcf-devel] [PATCH] Windows port
by Eric Blake
[caveat - this is my first time visiting the netcf list. Sorry if I'm
breaking any list protocols :)]
On 09/03/2010, Adam Stokes wrote:
General impressions - thanks for taking on this porting job! It's
interesting that the first contributed non-Fedora port is for Windows,
of all platforms.
>
> diff --git a/bootstrap b/bootstrap
> index f0653ef..351d58c 100755
> --- a/bootstrap
> +++ b/bootstrap
> @@ -62,6 +62,25 @@ c-ctype
> read-file
> safe-alloc
> warnings
> +sys_wait
> +sigaction
> +pthread
> +unistd
> +getdtablesize
> +signal
> +arpa_inet
> +sys_ioctl
> +getopt-posix
> +string
> +sys_socket
> +socket
> +netinet_in
> +vasprintf
> +fcntl
> +inet_ntop
> +inet_pton
> +close
> +setenv
> '
Can we get this list sorted alphabetically?
> +++ b/configure.ac
> @@ -16,7 +16,27 @@ AC_PROG_LIBTOOL
>
> dnl The backend driver. Right now hardcoded to initscripts, but
> dnl eventually needs to be configurable at buildtime
> -AM_CONDITIONAL([NETCF_DRIVER_INITSCRIPTS], [true])
> +dnl temporary, if win32 then dont build this.
> +AC_CANONICAL_HOST
> +
> +dnl WIN32
> +AC_MSG_CHECKING([for win32 platform])
> +PLATFORM_WIN32="no"
> +case "$host" in
> + *-*-mingw*)
> + PLATFORM_WIN32="yes"
> + NO_UNDEFINED="-Wl,--no-undefined"
> + ;;
> + *-*-cygwin*)
> + NO_UNDEFINED="-Wl,--no-undefined"
Not sure why you need this with a -Wl, prefix, since netcf uses libtool.
Shouldn't including '-no-undefined' in the appriate AM_LDFLAGS of
Makefile.am cover this?
>
> -AC_CHECK_HEADER([pthread.h],
> - [AC_CHECK_LIB([pthread],[pthread_join],[
> - AC_DEFINE([HAVE_LIBPTHREAD],[],[Define if pthread (-lpthread)])
> - AC_DEFINE([HAVE_PTHREAD_H],[],[Define if<pthread.h>])
> - LIBS="-lpthread $LIBS"
> - ])])
> +dnl check pthread functions
> +dnl pulled from:
> +dnl http://www.mail-archive.com/libvir-list@redhat.com/msg24187.html
> +old_LIBS=$LIBS
> +LIBS="$LIBS $LIB_PTHREAD"
> +AC_CHECK_FUNCS([pthread_sigmask pthread_mutexattr_init])
> +LIBS=$old_libs
This part looks sane to be broken into an independent patch.
> +++ b/mingw32-netcf.spec.in
> @@ -0,0 +1,95 @@
> +%global __strip %{_mingw32_strip}
> +%global __objdump %{_mingw32_objdump}
> +%global _use_internal_dependency_generator 0
> +%global __find_requires %{_mingw32_findrequires}
> +%global __find_provides %{_mingw32_findprovides}
To match mingw32-libvirt's example, this needs another line
%define __debug_install_post %{_mingw32_debug_install_post}
> +
> +%changelog
> +* Mon Sep 1 2010 Adam Stokes<ajs(a)redhat.com> - 0.1.6-2
> +- Update spec to not require .dll.a or *.la
> +- Fixed building of DLL
Technically, you should start mingw32-netcf at 0.1.6-1 (always match the
package version of the current non-mingw rpm, but track the -n of the
mingw builds independently, which means starting at -1).
> +
> +* Thu Apr 16 2010 Laine Stump<laine(a)redhat.com> - 0.1.6-1
> +- New version
No need to include changelog details for builds that did not exist for
mingw32-netcf.
> new file mode 100755
> index 0000000..d0d1687
> --- /dev/null
> +++ b/netcf-wininst.nsi
Sorry, I've never worked with .nsi files to be much of a help on this
part of the review.
> @@ -29,9 +32,11 @@ libnetcf_la_SOURCES = netcf.h netcf.c internal.h \
> ref.h list.h \
> xslt_ext.c $(DRIVER_SOURCES)
> libnetcf_la_LDFLAGS = -Wl,--version-script=netcf.syms \
> - -version-info $(LIBNETCF_VERSION_INFO)
> + -version-info $(LIBNETCF_VERSION_INFO) @NO_UNDEFINED@
In general, you should use $(NO_UNDEFINED) for AC_SUBST'd data. But
back to my earlier question, why not just blindly use:
-no-undefined
here, as it does not hurt on Linux, and since libtool can handle it a
lot better than manually going through -Wl, linker flags?
> datadir.h: $(top_builddir)/config.status
> - echo '#define DATADIR "$(datadir)"'> datadir.h
> + echo '#define NETCF_DATADIR "$(datadir)"'> datadir.h
Hmm, this renaming should probably be split into a separate patch.
> +++ b/src/ncftool.c
> @@ -784,7 +784,10 @@ int main(int argc, char **argv) {
> fprintf(stderr, "Failed to initialize netcf\n");
> if (ncf != NULL)
> print_netcf_error();
> +#ifndef WIN32
> + // FIXME: Need to find out why ncf_init is croaking
> exit(EXIT_FAILURE);
> +#endif
Does this really work for WIN32 but fail otherwise?
> }
> readline_init();
> if (optind< argc) {
> diff --git a/src/netcf.c b/src/netcf.c
> index 1a95332..96b6be7 100644
> --- a/src/netcf.c
> +++ b/src/netcf.c
> @@ -35,7 +35,11 @@
>
> #include "internal.h"
> #include "netcf.h"
> +#ifdef WIN32
> +#include "netcf_win.h"
Unrelated to your patch, but should netcf adopt the same cppi rules as
libvirt to make it easier to follow nested #ifdefs?
> +++ b/src/netcf_win.c
> @@ -0,0 +1,565 @@
> +#include<config.h>
> +#include<internal.h>
> +
> +#include<stdio.h>
> +#include<stdlib.h>
> +#include "netcf_win.h"
> +
> +#define MAX_TRIES 3
> +#define GAA_FLAGS ( GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_MULTICAST )
> +#define BUFSIZE 8192
> +
> +PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable) {
> + DWORD r = 0;
> + DWORD buf = 0;
> +
> + ipAddrTable = (PMIB_IPADDRTABLE) malloc(sizeof (MIB_IPADDRTABLE));
Since this is C, the cast is probably redundant (I'm not a fan of
casting malloc results, except when trying to satisfy C++).
> +PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES
> addrList) {
> + ULONG bufferLength = 0;
> + DWORD r;
> + int i;
> +
> + for(i = 0; i< 5; i++) {
Why 5? And why is this magic number not a #define?
> +/* All undefined routines in windows */
> +int drv_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml) {
> +#ifdef WIN32
> + return -1;
> +#endif
> +}
Hmm - this will cause compilation warnings or failure if this file is
compiled on any non-WIN32 platform (missing return value). And I think
it would be better to have these stubs next to the declaration of the
working versions in netcf.c (and not here in an independent file), as in:
#ifdef WIN32
/* No way to implement these on mingw for now... */
int drv_get_aug() { return -1; }
#else
int drv_get_aug() {
...
}
#endif
That also has the advantage of moving the #ifdefs outside of function
bodies, which aids in readability.
> +
> +int xasprintf(char **strp, const char *format, ...) {
> + va_list args;
> + int result;
> +
> + va_start (args, format);
> + result = vasprintf (strp, format, args);
> + va_end (args);
> + if (result< 0)
> + *strp = NULL;
> + return result;
> +}
Why are you reinventing a printf interface in a win-specific file?
Shouldn't this be in a file used by the entire project, if it is necessary?
> +static int list_interface_ids(struct netcf *ncf ATTRIBUTE_UNUSED,
> + int maxnames ATTRIBUTE_UNUSED,
> + char **names, unsigned int flags ATTRIBUTE_UNUSED,
> + const char *id_attr ATTRIBUTE_UNUSED) {
> + unsigned int nint = 0;
> +
> + PIP_ADAPTER_ADDRESSES addrList = NULL;
> + PIP_ADAPTER_ADDRESSES adapterp = NULL;
> + adapterp = _get_ip_adapter_info(addrList);
> + for (nint = 0; adapterp != NULL; nint++) {
> + if (names) {
> + char name[8192];
Shouldn't this use BUFSIZE, which you defined earlier? Also,
stack-allocating anything larger than 4k is dangerous, since it can lead
to silent program termination on stack overflow conditions where you end
up overshooting the 4k guard page.
> +const char *drv_mac_string(struct netcf_if *nif) {
> + // struct netcf *ncf = nif->ncf;
> + char mac[256];
Magic number? And given the name, it sounds like you are over-allocating.
> + sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X",
> + adapterp->PhysicalAddress[0],
> + adapterp->PhysicalAddress[1],
> + adapterp->PhysicalAddress[2],
> + adapterp->PhysicalAddress[3],
> + adapterp->PhysicalAddress[4],
> + adapterp->PhysicalAddress[5]);
> + nif->mac = strdup(mac);
Rather than risking a code audit question of whether this can overflow,
why not combine sprintf/strdup into a single asprintf from the get-go?
At which point, you don't even need the temporary mac[256].
> +int drv_if_ipaddresses(struct netcf_if *nif, char *ipBuf) {
> + PIP_ADAPTER_ADDRESSES addrList = NULL;
> + PIP_ADAPTER_ADDRESSES adapterp = NULL;
> + PMIB_IPADDRTABLE ipAddrTable = NULL;
> + PMIB_IPADDRTABLE ipAddrTableDup = NULL;
> + IN_ADDR ipAddr;
> + DWORD r = 0;
> + int i;
> +
> + if ((ipAddrTableDup = _get_ip_addr_table(ipAddrTable)) == NULL)
> + return -1;
> +
> + adapterp = _get_ip_adapter_info(addrList);
> + if (adapterp != NULL) {
> + while(adapterp) {
> + if (adapterp->OperStatus != 1)
> + continue;
This is a 100%-processor busy loop. Should you be sleeping to at least
allow some other thread to make progress?
> +++ b/src/netcf_win.h
> @@ -0,0 +1,93 @@
> +/*
> + * netcf-win.h: windows functions
> + *
> + * Copyright (C) 2009-2010 Red Hat Inc.
Is 2009 appropriate, if this is a new file this year?
> +
> +static int aug_put_xml(struct netcf *ncf, xmlDocPtr xml);
Why are you declaring static functions in a public header? Just declare
them in the .c file where they are used if they are truly static.
> +struct netcf_if *make_netcf_if(struct netcf *ncf, char *name);
> +int xasprintf(char **strp, const char *format, ...);
Leaving only the real exports, like these, in the header. Again, why is
xasprintf windows-specific? If it is useful to netcf in general, it
should be moved to a better file, and made namespace clean.
I have not tried a compile test, as there were enough surface issues to
be worth a patch respin first.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
13 years, 6 months
[PATCH] Register gnulib as a proper submodule
by Laine Stump
From: Laine Stump <laine(a)redhat.com>
Doing this ensures exact control over the gnulib version used for any
build of netcf.
---
.gitmodules | 3 +++
.gnulib | 1 +
bootstrap | 34 ++++++++++++++++++++--------------
3 files changed, 24 insertions(+), 14 deletions(-)
create mode 100644 .gitmodules
create mode 160000 .gnulib
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..7acb1ea
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "gnulib"]
+ path = .gnulib
+ url = git://git.sv.gnu.org/gnulib.git
diff --git a/.gnulib b/.gnulib
new file mode 160000
index 0000000..cc85acd
--- /dev/null
+++ b/.gnulib
@@ -0,0 +1 @@
+Subproject commit cc85acd7729af217a8f4820ecb36a9be816dba75
diff --git a/bootstrap b/bootstrap
index e560764..f64713d 100755
--- a/bootstrap
+++ b/bootstrap
@@ -33,25 +33,31 @@ do
esac
done
-cleanup_gnulib() {
- st=$?
- rm -fr .gnulib
- exit $st
-}
+# Get gnulib files.
case ${GNULIB_SRCDIR--} in
-)
- if [ ! -d .gnulib ]; then
+ echo "$0: getting gnulib files..."
+ git submodule init || exit $?
+ git submodule update || exit $?
+ GNULIB_SRCDIR=.gnulib
+ ;;
+*)
+ # Redirect the gnulib submodule to the directory on the command line
+ # if possible.
+ if test -d "$GNULIB_SRCDIR"/.git && \
+ git config --file .gitmodules submodule.gnulib.url >/dev/null; then
+ git submodule init
+ GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
+ git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
echo "$0: getting gnulib files..."
-
- trap cleanup_gnulib 1 2 13 15
-
- git clone --depth 1 git://git.sv.gnu.org/gnulib .gnulib ||
- cleanup_gnulib
-
- trap - 1 2 13 15
+ git submodule update || exit $?
+ GNULIB_SRCDIR=.gnulib
+ else
+ echo >&2 "$0: invalid gnulib srcdir: $GNULIB_SRCDIR"
+ exit 1
fi
- GNULIB_SRCDIR=.gnulib
+ ;;
esac
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
--
1.7.2.2
13 years, 6 months
[PATCH] build: allow bootstrap on fresh checkout again
by Eric Blake
* autogen.sh: Fix omission from last commit.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
If you already have ChangeLog lying around in your tree, you could
still build. But since my last commit, a fresh clone no longer
has one, and a missing ChangeLog upsets automake.
autogen.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index b0197c3..425c7b1 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -84,6 +84,7 @@ fi
mkdir -p $BUILD_AUX
+touch ChangeLog
$LIBTOOLIZE --copy --force
./bootstrap ${GNULIB_SRCDIR:+--gnulib-srcdir="$GNULIB_SRCDIR"}
aclocal -I gnulib/m4
--
1.7.2.2
13 years, 6 months