All,

Part 2/3 includes the ipvsadm package tool only.
It depends on the ipvs kernel modules patch 1/3
This patch includes code and build improvements following the review.

Mauro

commit 0774e5f9347943d4677f596d72cfadfc84dffcb9
Author: Mauro Mozzarelli <ma...@ezplanet.net>
Date:   Wed Feb 24 18:12:00 2016 +0000

    This ipvsadm package adds Linux IP Virtual Server capability to OpenWrt
    IPVS (IP Virtual Server) implements transport-layer load balancing inside 
the Linux kernel, so called Layer-4 switching.
    IPVS running on a host acts as a load balancer at the front of a cluster of 
real servers, it can direct requests for
    TCP/UDP based services to the real servers, and makes services of the real 
servers to appear as a virtual service on a
    single IP address.

    More information at: http://www.linuxvirtualserver.org/software/

    This package contains:
    - ipvsadm utility to configure IP VS tables, virtual and real servers

    Dependencies:
    - ipvs kernel modules configuration in patch 1 of 3

    Signed-off-by: Mauro Mozzarelli <ma...@ezplanet.net>

diff --git a/package/network/utils/ipvsadm/Makefile 
b/package/network/utils/ipvsadm/Makefile
new file mode 100644
index 0000000..6a38867
--- /dev/null
+++ b/package/network/utils/ipvsadm/Makefile
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2016 OpenWrt, Mauro Mozzarelli
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# AUTHOR: Mauro Mozzarelli
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ipvsadm
+PKG_VERSION:=1.26
+PKG_MAINTAINER:=Mauro Mozzarelli <ma...@ezplanet.net>
+PKG_LICENSE:=GPL-1.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.linuxvirtualserver.org/software/kernel-2.6/
+PKG_MD5SUM:=eac3ba3f62cd4dea2da353aeddd353a8
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/$(PKG_NAME)
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=IP Virtual Server Configuration Manager
+  URL:=http://www.linuxvirtualserver.org
+  DEPENDS:= +kmod-ipvs +libnl-tiny +libpopt
+endef
+
+TARGET_CFLAGS += \
+       -I$(STAGING_DIR)/usr/include/libnl-tiny -fPIC -DLIBIPVS_USE_NL 
-D_GNU_SOURCE
+
+MAKE_FLAGS += \
+       CFLAGS="$(TARGET_CFLAGS)" \
+       LIBS="-lnl-tiny -lpopt"
+
+define Package/ipvsadm/install
+       $(INSTALL_DIR) $(1)/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ipvsadm $(1)/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ipvsadm-save $(1)/sbin/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/ipvsadm-restore $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,$(PKG_NAME)))
diff --git a/package/network/utils/ipvsadm/patches/001-ipvsadm.patch 
b/package/network/utils/ipvsadm/patches/001-ipvsadm.patch
new file mode 100644
index 0000000..bb93116
--- /dev/null
+++ b/package/network/utils/ipvsadm/patches/001-ipvsadm.patch
@@ -0,0 +1,154 @@
+diff -Naur ipvsadm-1.26/ipvsadm-restore ipvsadm-1.26.owrt/ipvsadm-restore
+--- ipvsadm-1.26/ipvsadm-restore       2008-09-18 16:57:37.000000000 +0100
++++ ipvsadm-1.26.owrt/ipvsadm-restore  2016-02-24 16:21:07.749719555 +0000
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+ #      ipvsadm-restore - Restore IPVS rules
+ #
+ #      A very simple wrapper to restore IPVS rules
+@@ -11,12 +11,15 @@
+ #      This file:
+ #
+ #      ChangeLog
++#
++#      M. Mozzarelli       :  Modified for compatibility with OpenWrt
++#                          :  uses /bin/sh; removed /usr/local bin dirs from 
PATH
+ #      Horms               :        Clear IPVS rules before adding from STDIN
+ #      Horms               :        Filter out "^#"
+ #
+ #
+
+-PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
++PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+ # All the work is actually done in ipvsadm, hooray
+
+diff -Naur ipvsadm-1.26/ipvsadm-save ipvsadm-1.26.owrt/ipvsadm-save
+--- ipvsadm-1.26/ipvsadm-save  2008-09-18 16:57:37.000000000 +0100
++++ ipvsadm-1.26.owrt/ipvsadm-save     2016-02-24 16:19:48.870617326 +0000
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+ #      ipvsadm-save - Save IPVS rules
+ #
+ #      A very simple wrapper to save IPVS rules
+@@ -12,10 +12,12 @@
+ #
+ #      ChangeLog
+ #
++#    M. Mozzarelli          :  Modified for compatibility with OpenWrt
++#                           :  uses /bin/sh; removed /usr/local bin dirs from 
PATH
+ #      Wensong Zhang          :  Added the "-n" option and the help()
+ #
+
+-PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
++PATH=/bin:/sbin:/usr/bin:/usr/sbin
+ NUMERIC=""
+
+
+diff -Naur ipvsadm-1.26/libipvs/ip_vs.h ipvsadm-1.26.owrt/libipvs/ip_vs.h
+--- ipvsadm-1.26/libipvs/ip_vs.h       2011-02-07 02:38:57.000000000 +0000
++++ ipvsadm-1.26.owrt/libipvs/ip_vs.h  2016-02-24 14:20:11.885361270 +0000
+@@ -10,6 +10,7 @@
+ #include <sys/socket.h>
+ #include <arpa/inet.h>
+ #include <linux/types.h>      /* For __beXX types in userland */
++#include <sys/types.h>
+
+ #ifdef LIBIPVS_USE_NL
+ #include <netlink/netlink.h>
+diff -Naur ipvsadm-1.26/libipvs/libipvs.c ipvsadm-1.26.owrt/libipvs/libipvs.c
+--- ipvsadm-1.26/libipvs/libipvs.c     2011-02-07 02:38:57.000000000 +0000
++++ ipvsadm-1.26.owrt/libipvs/libipvs.c        2016-02-24 14:24:12.324543552 
+0000
+@@ -32,7 +32,7 @@
+ struct ip_vs_getinfo ipvs_info;
+
+ #ifdef LIBIPVS_USE_NL
+-static struct nl_handle *sock = NULL;
++static struct nl_sock *sock = NULL;
+ static int family, try_nl = 1;
+ #endif
+
+@@ -73,7 +73,7 @@
+ {
+       int err = EINVAL;
+
+-      sock = nl_handle_alloc();
++      sock = nl_socket_alloc();
+       if (!sock) {
+               nlmsg_free(msg);
+               return -1;
+@@ -88,7 +88,7 @@
+
+       /* To test connections and set the family */
+       if (msg == NULL) {
+-              nl_handle_destroy(sock);
++              nl_socket_free(sock);
+               sock = NULL;
+               return 0;
+       }
+@@ -104,12 +104,12 @@
+
+       nlmsg_free(msg);
+
+-      nl_handle_destroy(sock);
++      nl_socket_free(sock);
+
+       return 0;
+
+ fail_genl:
+-      nl_handle_destroy(sock);
++      nl_socket_free(sock);
+       sock = NULL;
+       nlmsg_free(msg);
+       errno = err;
+diff -Naur ipvsadm-1.26/Makefile ipvsadm-1.26.owrt/Makefile
+--- ipvsadm-1.26/Makefile      2011-02-08 00:24:23.000000000 +0000
++++ ipvsadm-1.26.owrt/Makefile 2016-02-24 14:38:06.193778097 +0000
+@@ -11,6 +11,9 @@
+ #
+ #      ChangeLog
+ #
++#      M. Mozzarelli  :   Amended to support build and deployment in OpenWrt
++#                     :   excludes manuals and init script installation
++#                     :   uses libnl-tiny instead of libnl
+ #      Wensong        :   Modified the Makefile and the spec files so
+ #                     :   that rpms can be created with ipvsadm alone
+ #      P.Copeland     :   Modified the Makefile and the spec files so
+@@ -37,18 +40,18 @@
+
+ CC            = gcc
+ INCLUDE               =
+-SBIN          = $(BUILD_ROOT)/sbin
++SBIN          = $(DESTDIR)/sbin
+ MANDIR                = usr/man
+ MAN           = $(BUILD_ROOT)/$(MANDIR)/man8
+-INIT          = $(BUILD_ROOT)/etc/rc.d/init.d
++INIT          = $(DESTDIR)/etc/rc.d/init.d
+ MKDIR         = mkdir
+ INSTALL               = install
+ STATIC_LIBS   = libipvs/libipvs.a
+
+ ifeq "${ARCH}" "sparc64"
+-    CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe 
-mcpu=ultrasparc -mcmodel=medlow
++    CFLAGS += -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe 
-mcpu=ultrasparc -mcmodel=medlow
+ else
+-    CFLAGS = -Wall -Wunused -Wstrict-prototypes -g
++    CFLAGS += -Wall -Wunused -Wstrict-prototypes -g
+ endif
+
+
+@@ -104,12 +107,6 @@
+               $(INSTALL) -m 0755 ipvsadm $(SBIN)
+               $(INSTALL) -m 0755 ipvsadm-save $(SBIN)
+               $(INSTALL) -m 0755 ipvsadm-restore $(SBIN)
+-              [ -d $(MAN) ] || $(MKDIR) -p $(MAN)
+-              $(INSTALL) -m 0644 ipvsadm.8 $(MAN)
+-              $(INSTALL) -m 0644 ipvsadm-save.8 $(MAN)
+-              $(INSTALL) -m 0644 ipvsadm-restore.8 $(MAN)
+-              [ -d $(INIT) ] || $(MKDIR) -p $(INIT)
+-              $(INSTALL) -m 0755 ipvsadm.sh $(INIT)/ipvsadm
+
+ clean:
+               rm -f ipvsadm $(NAME).spec $(NAME)-$(VERSION).tar.gz
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to