diff --git a/.gitignore b/.gitignore
index f7b835bd4a..671f4e0cbd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,7 +46,6 @@ stamp-h1
# Dependency Folder #
#####################
deps/
-fpmsyncd/fpm/
# Executables #
###############
diff --git a/Makefile.am b/Makefile.am
index e4a47246f9..3d8b93e884 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1 @@
-SUBDIRS = neighsyncd intfsyncd portsyncd orchagent swssconfig
-
-if FPM
-SUBDIRS += fpmsyncd
-endif
+SUBDIRS = fpmsyncd neighsyncd intfsyncd portsyncd orchagent swssconfig
diff --git a/README.md b/README.md
index f0acbe70b0..ecbe5e7d8e 100644
--- a/README.md
+++ b/README.md
@@ -35,11 +35,6 @@ Checkout the source: `git clone https://github.com/Azure/sonic-swss.git` and ins
Get SAI header files into /usr/include/sai. Put the SAI header files that you use to compile
libsairedis into /usr/include/sai
-Get `fpm.h` header file before compiling:
-
- mkdir fpmsyncd/fpm
- wget http://git.savannah.gnu.org/cgit/quagga.git/plain/fpm/fpm.h -O fpmsyncd/fpm/fpm.h
-
Install prerequisite packages:
sudo apt-get install libswsscommon libswsscommon-dev libsairedis libsairedis-dev
@@ -47,7 +42,7 @@ Install prerequisite packages:
You can compile and install from source using:
./autogen.sh
- ./configure -with-fpm=fpm
+ ./configure
make && sudo make install
You can also build a debian package using:
diff --git a/ThirdPartyLicenses.txt b/ThirdPartyLicenses.txt
new file mode 100644
index 0000000000..1db5eb3313
--- /dev/null
+++ b/ThirdPartyLicenses.txt
@@ -0,0 +1,25 @@
+Third Party Notices
+
+This Microsoft Open Source project incorporates material from the project(s) listed below
+(Third Party Code). Microsoft is not the original author of the Third Party Code. Microsoft
+reserves all other rights not expressly granted, whether by implication, estoppel or otherwise.
+
+1. fpm.h https://github.com/opensourcerouting/quagga/blob/master/fpm/fpm.h
+Copyright (C) 2012 by Open Source Routing.
+Copyright (C) 2012 by Internet Systems Consortium, Inc. ("ISC")
+
+ISC License
+
+Permission to use, copy, modify, and/or distribute this software
+for any purpose with or without fee is hereby granted, provided
+that the above copyright notice and this permission notice appear
+in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/configure.ac b/configure.ac
index 5320886628..e14e1fc586 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,18 +23,6 @@ esac],[debug=false])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
-AC_ARG_WITH(fpm,
-[ --with-fpm=
Compiles using qauggas fpm library],
-AC_MSG_NOTICE(Using fpmi path from:$with_fpm), with_fpm="none")
-
-FPM_PATH=
-if test "x$with_fpm" != xnone; then
-FPM_PATH=$with_fpm
-fi
-AC_SUBST(FPM_PATH)
-AM_CONDITIONAL(FPM, test "x$with_fpm" != xnone)
-
-
CFLAGS_COMMON="-std=c++11 -Wall -fPIC -Wno-write-strings -I/usr/include/libnl3 -I/usr/include/swss"
AC_SUBST(CFLAGS_COMMON)
diff --git a/debian/rules b/debian/rules
index 2809edbb5a..6db7a93789 100755
--- a/debian/rules
+++ b/debian/rules
@@ -28,7 +28,7 @@ include /usr/share/dpkg/default.mk
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
override_dh_auto_configure:
- dh_auto_configure -- --with-fpm=fpm/
+ dh_auto_configure --
override_dh_auto_install:
dh_auto_install
diff --git a/fpmsyncd/fpm/fpm.h b/fpmsyncd/fpm/fpm.h
new file mode 100644
index 0000000000..96f05f4865
--- /dev/null
+++ b/fpmsyncd/fpm/fpm.h
@@ -0,0 +1,273 @@
+/*
+ * Public definitions pertaining to the Forwarding Plane Manager component.
+ *
+ * Permission is granted to use, copy, modify and/or distribute this
+ * software under either one of the licenses below.
+ *
+ * Note that if you use other files from the Quagga tree directly or
+ * indirectly, then the licenses in those files still apply.
+ *
+ * Please retain both licenses below when modifying this code in the
+ * Quagga tree.
+ *
+ * Copyright (C) 2012 by Open Source Routing.
+ * Copyright (C) 2012 by Internet Systems Consortium, Inc. ("ISC")
+ */
+
+/*
+ * License Option 1: GPL
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program 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 General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * License Option 2: ISC License
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _FPM_H
+#define _FPM_H
+
+/*
+ * The Forwarding Plane Manager (FPM) is an optional component that
+ * may be used in scenarios where the router has a forwarding path
+ * that is distinct from the kernel, commonly a hardware-based fast
+ * path. It is responsible for programming forwarding information
+ * (such as routes and nexthops) in the fast path.
+ *
+ * In Quagga, the Routing Information Base is maintained in the
+ * 'zebra' infrastructure daemon. Routing protocols communicate their
+ * best routes to zebra, and zebra computes the best route across
+ * protocols for each prefix. This latter information comprises the
+ * bulk of the Forwarding Information Base.
+ *
+ * This header file defines a point-to-point interface using which
+ * zebra can update the FPM about changes in routes. The communication
+ * takes place over a stream socket. The FPM listens on a well-known
+ * TCP port, and zebra initiates the connection.
+ *
+ * All messages sent over the connection start with a short FPM
+ * header, fpm_msg_hdr_t. In the case of route add/delete messages,
+ * the header is followed by a netlink message. Zebra should send a
+ * complete copy of the forwarding table(s) to the FPM, including
+ * routes that it may have picked up from the kernel.
+ *
+ * The FPM interface uses replace semantics. That is, if a 'route add'
+ * message for a prefix is followed by another 'route add' message, the
+ * information in the second message is complete by itself, and replaces
+ * the information sent in the first message.
+ *
+ * If the connection to the FPM goes down for some reason, the client
+ * (zebra) should send the FPM a complete copy of the forwarding
+ * table(s) when it reconnects.
+ */
+
+#define FPM_DEFAULT_PORT 2620
+
+/*
+ * Largest message that can be sent to or received from the FPM.
+ */
+#define FPM_MAX_MSG_LEN 4096
+
+/*
+ * Header that precedes each fpm message to/from the FPM.
+ */
+typedef struct fpm_msg_hdr_t_
+{
+ /*
+ * Protocol version.
+ */
+ uint8_t version;
+
+ /*
+ * Type of message, see below.
+ */
+ uint8_t msg_type;
+
+ /*
+ * Length of entire message, including the header, in network byte
+ * order.
+ *
+ * Note that msg_len is rounded up to make sure that message is at
+ * the desired alignment. This means that some payloads may need
+ * padding at the end.
+ */
+ uint16_t msg_len;
+} fpm_msg_hdr_t;
+
+/*
+ * The current version of the FPM protocol is 1.
+ */
+#define FPM_PROTO_VERSION 1
+
+typedef enum fpm_msg_type_e_ {
+ FPM_MSG_TYPE_NONE = 0,
+
+ /*
+ * Indicates that the payload is a completely formed netlink
+ * message.
+ */
+ FPM_MSG_TYPE_NETLINK = 1,
+} fpm_msg_type_e;
+
+/*
+ * The FPM message header is aligned to the same boundary as netlink
+ * messages (4). This means that a netlink message does not need
+ * padding when encapsulated in an FPM message.
+ */
+#define FPM_MSG_ALIGNTO 4
+
+/*
+ * fpm_msg_align
+ *
+ * Round up the given length to the desired alignment.
+ */
+static inline size_t
+fpm_msg_align (size_t len)
+{
+ return (len + FPM_MSG_ALIGNTO - 1) & ~(FPM_MSG_ALIGNTO - 1);
+}
+
+/*
+ * The (rounded up) size of the FPM message header. This ensures that
+ * the message payload always starts at an aligned address.
+ */
+#define FPM_MSG_HDR_LEN (fpm_msg_align (sizeof (fpm_msg_hdr_t)))
+
+/*
+ * fpm_data_len_to_msg_len
+ *
+ * The length value that should be placed in the msg_len field of the
+ * header for a *payload* of size 'data_len'.
+ */
+static inline size_t
+fpm_data_len_to_msg_len (size_t data_len)
+{
+ return fpm_msg_align (data_len) + FPM_MSG_HDR_LEN;
+}
+
+/*
+ * fpm_msg_data
+ *
+ * Pointer to the payload of the given fpm header.
+ */
+static inline void *
+fpm_msg_data (fpm_msg_hdr_t *hdr)
+{
+ return ((char*) hdr) + FPM_MSG_HDR_LEN;
+}
+
+/*
+ * fpm_msg_len
+ */
+static inline size_t
+fpm_msg_len (const fpm_msg_hdr_t *hdr)
+{
+ return ntohs (hdr->msg_len);
+}
+
+/*
+ * fpm_msg_data_len
+ */
+static inline size_t
+fpm_msg_data_len (const fpm_msg_hdr_t *hdr)
+{
+ return (fpm_msg_len (hdr) - FPM_MSG_HDR_LEN);
+}
+
+/*
+ * fpm_msg_next
+ *
+ * Move to the next message in a buffer.
+ */
+static inline fpm_msg_hdr_t *
+fpm_msg_next (fpm_msg_hdr_t *hdr, size_t *len)
+{
+ size_t msg_len;
+
+ msg_len = fpm_msg_len (hdr);
+
+ if (len) {
+ if (*len < msg_len)
+ {
+ assert(0);
+ return NULL;
+ }
+ *len -= msg_len;
+ }
+
+ return (fpm_msg_hdr_t *) (((char*) hdr) + msg_len);
+}
+
+/*
+ * fpm_msg_hdr_ok
+ *
+ * Returns TRUE if a message header looks well-formed.
+ */
+static inline int
+fpm_msg_hdr_ok (const fpm_msg_hdr_t *hdr)
+{
+ size_t msg_len;
+
+ if (hdr->msg_type == FPM_MSG_TYPE_NONE)
+ return 0;
+
+ msg_len = fpm_msg_len (hdr);
+
+ if (msg_len < FPM_MSG_HDR_LEN || msg_len > FPM_MAX_MSG_LEN)
+ return 0;
+
+ if (fpm_msg_align (msg_len) != msg_len)
+ return 0;
+
+ return 1;
+}
+
+/*
+ * fpm_msg_ok
+ *
+ * Returns TRUE if a message looks well-formed.
+ *
+ * @param len The length in bytes from 'hdr' to the end of the buffer.
+ */
+static inline int
+fpm_msg_ok (const fpm_msg_hdr_t *hdr, size_t len)
+{
+ if (len < FPM_MSG_HDR_LEN)
+ return 0;
+
+ if (!fpm_msg_hdr_ok (hdr))
+ return 0;
+
+ if (fpm_msg_len (hdr) > len)
+ return 0;
+
+ return 1;
+}
+
+#endif /* _FPM_H */