[iccpd] build iccpd deb by auto tools (#4540)

* [iccpd] build iccpd deb by auto tools
This commit is contained in:
Tyler Li 2020-05-22 00:12:51 +08:00 committed by GitHub
parent 5fefee67d7
commit 2398992d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 163 additions and 143 deletions

View File

@ -9,7 +9,6 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y ebtables apt-get install -y ebtables
RUN apt-get -y install -f kmod
COPY \ COPY \
{% for deb in docker_iccpd_debs.split(' ') -%} {% for deb in docker_iccpd_debs.split(' ') -%}

View File

@ -1,14 +1,22 @@
# docker image for iccpd agent # docker image for iccpd agent
DOCKER_ICCPD = docker-iccpd.gz DOCKER_ICCPD_STEM = docker-iccpd
$(DOCKER_ICCPD)_PATH = $(DOCKERS_PATH)/docker-iccpd DOCKER_ICCPD = $(DOCKER_ICCPD_STEM).gz
DOCKER_ICCPD_DBG = $(DOCKER_ICCPD_STEM)-$(DBG_IMAGE_MARK).gz
$(DOCKER_ICCPD)_PATH = $(DOCKERS_PATH)/$(DOCKER_ICCPD_STEM)
$(DOCKER_ICCPD)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(ICCPD) $(DOCKER_ICCPD)_DEPENDS += $(SWSS) $(REDIS_TOOLS) $(ICCPD)
$(DOCKER_ICCPD)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS)
$(DOCKER_ICCPD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) $(ICCPD_DBG)
$(DOCKER_ICCPD)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES)
$(DOCKER_ICCPD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) $(DOCKER_ICCPD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH)
ifeq ($(ENABLE_ICCPD), y) ifeq ($(ENABLE_ICCPD), y)
SONIC_DOCKER_IMAGES += $(DOCKER_ICCPD) SONIC_DOCKER_IMAGES += $(DOCKER_ICCPD)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ICCPD) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ICCPD)
SONIC_STRETCH_DOCKERS += $(DOCKER_ICCPD) SONIC_STRETCH_DOCKERS += $(DOCKER_ICCPD)
SONIC_DOCKER_DBG_IMAGES += $(DOCKER_ICCPD_DBG)
SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_ICCPD_DBG)
SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_ICCPD_DBG)
endif endif
$(DOCKER_ICCPD)_CONTAINER_NAME = iccpd $(DOCKER_ICCPD)_CONTAINER_NAME = iccpd

View File

@ -6,8 +6,14 @@ ICCPD = iccpd_$(ICCPD_VERSION)_$(CONFIGURED_ARCH).deb
$(ICCPD)_DEPENDS += $(LIBNL_GENL3_DEV) $(LIBNL_CLI_DEV) $(ICCPD)_DEPENDS += $(LIBNL_GENL3_DEV) $(LIBNL_CLI_DEV)
$(ICCPD)_RDEPENDS += $(LIBNL_GENL3) $(LIBNL_CLI) $(ICCPD)_RDEPENDS += $(LIBNL_GENL3) $(LIBNL_CLI)
$(ICCPD)_SRC_PATH = $(SRC_PATH)/iccpd $(ICCPD)_SRC_PATH = $(SRC_PATH)/iccpd
SONIC_MAKE_DEBS += $(ICCPD) SONIC_DPKG_DEBS += $(ICCPD)
# Export these variables so they can be used in a sub-make ICCPD_DBG = iccpd-dbg_$(ICCPD_VERSION)_$(CONFIGURED_ARCH).deb
export ICCPD_VERSION $(ICCPD_DBG)_DEPENDS += $(ICCPD)
export ICCPD $(ICCPD_DBG)_RDEPENDS += $(ICCPD)
$(eval $(call add_derived_package,$(ICCPD),$(ICCPD_DBG)))
# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list}
# are archived into debug one image to facilitate debugging.
#
DBG_SRC_ARCHIVE += iccpd

View File

@ -1,37 +0,0 @@
.ONESHELL:
SHELL = /bin/bash
.SHELLFLAGS += -e
MAIN_TARGET = iccpd_$(ICCPD_VERSION)_$(CONFIGURED_ARCH).deb
DEB_PATH = debian
all: iccpd-build mclagdctl-build
iccpd-build:
make -C src
mclagdctl-build:
make -C src/mclagdctl
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
make all
if [ ! -d $(DEB_PATH)/usr/bin ]; then
mkdir -p $(DEB_PATH)/usr/bin
fi
cp iccpd $(DEB_PATH)/usr/bin/iccpd
cp src/mclagdctl/mclagdctl $(DEB_PATH)/usr/bin/mclagdctl
chmod +x $(DEB_PATH)/usr/bin/iccpd
chmod +x $(DEB_PATH)/usr/bin/mclagdctl
md5sum $(DEB_PATH)/usr/bin/iccpd > $(DEB_PATH)/DEBIAN/md5sums
md5sum $(DEB_PATH)/usr/bin/mclagdctl >> $(DEB_PATH)/DEBIAN/md5sums
sed -i "s/Package: .*/Package: iccpd-$(ICCPD_VERSION)-$(CONFIGURED_ARCH)/g" $(DEB_PATH)/DEBIAN/control
sed -i "s/Architecture: .*/Architecture: $(CONFIGURED_ARCH)/g" $(DEB_PATH)/DEBIAN/control
dpkg-deb -b $(DEB_PATH) $(DEST)/$(MAIN_TARGET)
clean: iccpd-clean mclagdctl-clean
iccpd-clean:
make -C src clean
mclagdctl-clean:
make -C src/mclagdctl clean

1
src/iccpd/Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = src

6
src/iccpd/autogen.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
libtoolize --force --copy &&
autoreconf --force --install -I m4
rm -Rf autom4te.cache

32
src/iccpd/configure.ac Normal file
View File

@ -0,0 +1,32 @@
AC_INIT([iccpd],[0.5])
AC_CONFIG_SRCDIR([])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([foreign])
AC_LANG_C
AC_PROG_CC
AC_PROG_LIBTOOL
AC_HEADER_STDC
AC_ARG_ENABLE(debug,
[ --enable-debug Compile with debugging flags],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS_COMMON="-Wno-unused-result"
AC_SUBST(CFLAGS_COMMON)
AC_CONFIG_FILES([
Makefile
src/Makefile
src/mclagdctl/Makefile
])
AC_OUTPUT

View File

@ -1,12 +0,0 @@
Package: iccpd-0.0.5-amd64
Source: nps
Version: 0.0.5
Architecture: amd64
Maintainer: Simon Ji <Simon.Ji@nephosinc.com>
Installed-Size: 1508
Depends:
Section: main
Priority: extra
Homepage: https://github.com/NephosInc/SONiC
Description:

View File

@ -0,0 +1,6 @@
sonic (0.0.5) stable; urgency=medium
* Initial release.
-- Tyler Li <tyler.li@mediatek.com> Thu, 23 Apr 2020 10:00:00 +0800

1
src/iccpd/debian/compat Normal file
View File

@ -0,0 +1 @@
10

18
src/iccpd/debian/control Normal file
View File

@ -0,0 +1,18 @@
Source: sonic
Maintainer: Tyler Li <tyler.li@mediatek.com>
Section: net
Priority: optional
Build-Depends: dh-exec (>=0.3), debhelper (>= 9), autotools-dev
Standards-Version: 0.0.5
Package: iccpd
Architecture: any
Depends: ${shlibs:Depends}
Description: This package contains Inter-Chassis Control Protocol for SONiC project.
Package: iccpd-dbg
Architecture: any
Section: debug
Priority: extra
Depends: iccpd (=${binary:Version})
Description: debugging symbols for iccpd

34
src/iccpd/debian/rules Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
# main packaging script based on dh7 syntax
%:
dh $@ --with autotools-dev
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
override_dh_auto_install:
dh_auto_install --destdir=debian/iccpd
override_dh_strip:
dh_strip --dbg-package=iccpd-dbg

View File

@ -31,6 +31,7 @@
#include <sys/queue.h> #include <sys/queue.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <pthread.h>
#include "../include/app_csm.h" #include "../include/app_csm.h"
#include "../include/msg_format.h" #include "../include/msg_format.h"

View File

@ -35,6 +35,7 @@
#include <unistd.h> #include <unistd.h>
struct CSM; struct CSM;
struct System;
#define CONNECT_INTERVAL_SEC 1 #define CONNECT_INTERVAL_SEC 1
#define CONNECT_TIMEOUT_MSEC 100 #define CONNECT_TIMEOUT_MSEC 100

View File

@ -1,55 +0,0 @@
LIBNL_CFLAGS = -I/usr/include/libnl3
LIBNL_LIBS = -lnl-cli-3 -lnl-genl-3 -lnl-nf-3 -lnl-route-3 -lnl-3
CC = gcc
SOURCES = app_csm.c cmd_option.c iccp_cli.c iccp_cmd_show.c iccp_cmd.c \
iccp_csm.c iccp_ifm.c iccp_main.c logger.c \
port.c scheduler.c system.c iccp_consistency_check.c \
mlacp_link_handler.c \
mlacp_sync_prepare.c mlacp_sync_update.c\
mlacp_fsm.c \
iccp_netlink.c
OBJECTS = app_csm.o cmd_option.o iccp_cli.o iccp_cmd_show.o iccp_cmd.o \
iccp_csm.o iccp_ifm.o iccp_main.o logger.o \
port.o scheduler.o system.o iccp_consistency_check.o\
mlacp_link_handler.o \
mlacp_sync_prepare.o mlacp_sync_update.o \
mlacp_fsm.o \
iccp_netlink.o
HEADERS = ../include/app_csm.h ../include/cmd_option.h ../include/iccp_cli.h \
../include/iccp_cmd_show.h \
../include/iccp_csm.h ../include/iccp_ifm.h \
../include/logger.h ../include/mlacp_fsm.h \
../include/mlacp_tlv.h ../include/msg_format.h ../include/port.h \
../include/scheduler.h ../include/system.h \
../include/iccp_consistency_check.h ../include/route_info.h \
../include/iccp_netlink.h
//CFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security $(LIBNL_CFLAGS) -I../include/
CFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -I../include/ $(LIBNL_CFLAGS)
LDFLAGS = $(LIBNL_LIBS) -lpthread
LDADD = $(LIBZEBRA_BIN)
all: iccpd
%.o: %.c $(HEADERS)
iccpd: $(OBJECTS)
$(CC) -o ../iccpd $(OBJECTS) $(LDFLAGS)
DEPS = $(patsubst %.o, %.d, $(OBJECTS))
-include $(DEPS)
%.d:%.c
@set -e; rm -f $@; \
gcc -MM $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
.PHONY: clean
clean:
-rm -f $(OBJECTS) $(DEPS) ../iccpd

22
src/iccpd/src/Makefile.am Normal file
View File

@ -0,0 +1,22 @@
SUBDIRS = mclagdctl
INCLUDES = -I$(top_srcdir)/include -I/usr/include/libnl3
bin_PROGRAMS = iccpd
if DEBUG
DBGFLAGS = -ggdb -DDEBUG
else
DBGFLAGS = -g -DNDEBUG
endif
iccpd_SOURCES = \
app_csm.c cmd_option.c iccp_cli.c iccp_cmd_show.c iccp_cmd.c \
iccp_csm.c iccp_ifm.c iccp_main.c logger.c \
port.c scheduler.c system.c iccp_consistency_check.c \
mlacp_link_handler.c \
mlacp_sync_prepare.c mlacp_sync_update.c\
mlacp_fsm.c \
iccp_netlink.c
iccpd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON)
iccpd_LDADD = -lnl-genl-3 -lnl-route-3 -lnl-3 -lpthread

View File

@ -691,7 +691,7 @@ void do_arp_update_from_reply_packet(unsigned int ifindex, unsigned int addr, ui
if (!verify_arp) if (!verify_arp)
return; return;
if (iccp_check_if_addr_from_netlink(AF_INET, &addr, arp_lif)) if (iccp_check_if_addr_from_netlink(AF_INET, (uint8_t *)&addr, arp_lif))
{ {
ICCPD_LOG_DEBUG(__FUNCTION__, "ARP %s is identical with the ip address of interface %s", ICCPD_LOG_DEBUG(__FUNCTION__, "ARP %s is identical with the ip address of interface %s",
show_ip_str(arp_msg->ipv4_addr), arp_lif->name); show_ip_str(arp_msg->ipv4_addr), arp_lif->name);

View File

@ -1,28 +0,0 @@
C = gcc
SOURCES = \
mclagdctl.c
OBJECTS = \
mclagdctl.o
HEADERS = \
mclagdctl.h
CFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security
LDFLAGS =
LDADD =
all: mclagdctl
%.o: %.c $(HEADERS)
mclagdctl: $(OBJECTS)
$(CC) -o ./mclagdctl $(OBJECTS) $(LDFLAGS)
.PHONY: clean
clean:
-rm -f $(OBJECTS) ./mclagdctl

View File

@ -0,0 +1,10 @@
bin_PROGRAMS = mclagdctl
if DEBUG
DBGFLAGS = -ggdb -DDEBUG
else
DBGFLAGS = -g -DNDEBUG
endif
mclagdctl_SOURCES = mclagdctl.c
mclagdctl_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON)

View File

@ -1,5 +1,5 @@
/* /*
/* Copyright(c) 2016-2019 Nephos. * Copyright(c) 2016-2019 Nephos.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@ -21,6 +21,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <getopt.h> #include <getopt.h>

View File

@ -370,7 +370,7 @@ int mlacp_prepare_for_arp_info(struct CSM* csm, char* buf, size_t max_buf_size,
tlv->icc_parameter.type = htons(TLV_T_MLACP_ARP_INFO); tlv->icc_parameter.type = htons(TLV_T_MLACP_ARP_INFO);
} }
ArpData = (struct mLACPMACData *)&buf[sizeof(ICCHdr) + sizeof(struct mLACPARPInfoTLV) + sizeof(struct ARPMsg) * count]; ArpData = (struct ARPMsg *)&buf[sizeof(ICCHdr) + sizeof(struct mLACPARPInfoTLV) + sizeof(struct ARPMsg) * count];
ArpData->op_type = arp_msg->op_type; ArpData->op_type = arp_msg->op_type;
sprintf(ArpData->ifname, "%s", arp_msg->ifname); sprintf(ArpData->ifname, "%s", arp_msg->ifname);

View File

@ -28,6 +28,8 @@
#include "../include/port.h" #include "../include/port.h"
#include "../include/system.h" #include "../include/system.h"
#include "../include/iccp_csm.h" #include "../include/iccp_csm.h"
#include "../include/iccp_netlink.h"
#include "../include/scheduler.h"
void local_if_init(struct LocalInterface* local_if) void local_if_init(struct LocalInterface* local_if)
{ {

View File

@ -731,7 +731,10 @@ int scheduler_unregister_sock_read_event_callback(struct CSM* csm)
return MCLAG_ERROR; return MCLAG_ERROR;
} }
if (csm->sock_fd > 0)
{
FD_CLR(csm->sock_fd, &(sys->readfd)); FD_CLR(csm->sock_fd, &(sys->readfd));
}
return 0; return 0;
} }