From d9c8f86889a94ac929f698e3cfd1ce35e98272c0 Mon Sep 17 00:00:00 2001 From: Godopu Date: Thu, 27 Aug 2026 14:09:11 +0000 Subject: [PATCH] Fix OpenFlow compilation with modern GCC/glibc and improve install.sh -fw support --- util/install.sh | 43 ++++++++----- util/openflow-patches/gcc-glibc.patch | 88 +++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 14 deletions(-) create mode 100644 util/openflow-patches/gcc-glibc.patch diff --git a/util/install.sh b/util/install.sh index bf4492d..60d7b64 100755 --- a/util/install.sh +++ b/util/install.sh @@ -242,15 +242,22 @@ function of { fi # was: git clone git://openflowswitch.org/openflow.git # Use our own fork on github for now: - git clone https://github.com/mininet/openflow + if [ ! -d "openflow" ]; then + git clone https://github.com/mininet/openflow + fi cd $BUILD_DIR/openflow - # Patch controller to handle more than 16 switches - patch -p1 < $MININET_DIR/mininet/util/openflow-patches/controller.patch + # Patch controller to handle more than 16 switches and fix modern gcc/glibc issues + if [ -f "$MININET_DIR/mininet/util/openflow-patches/controller.patch" ]; then + patch -p1 -N -r - < "$MININET_DIR/mininet/util/openflow-patches/controller.patch" || true + fi + if [ -f "$MININET_DIR/mininet/util/openflow-patches/gcc-glibc.patch" ]; then + patch -p1 -N -r - < "$MININET_DIR/mininet/util/openflow-patches/gcc-glibc.patch" || true + fi # Resume the install: ./boot.sh - ./configure + CFLAGS="-g -O2 -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -Wno-error=format -Wno-error=implicit-function-declaration -Wno-error=address-of-packed-member -Wno-error=discarded-qualifiers" ./configure make sudo make install cd $BUILD_DIR @@ -300,7 +307,7 @@ function of13 { function install_wireshark { - if ! which wireshark; then + if ! which wireshark &>/dev/null && ! which tshark &>/dev/null; then echo "Installing Wireshark" if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then $install wireshark wireshark-gnome @@ -313,29 +320,37 @@ function install_wireshark { # Copy coloring rules: OF is white-on-blue: echo "Optionally installing wireshark color filters" - mkdir -p $HOME/.wireshark - cp -n $MININET_DIR/mininet/util/colorfilters $HOME/.wireshark + mkdir -p $HOME/.wireshark $HOME/.config/wireshark + [ -f $MININET_DIR/mininet/util/colorfilters ] && cp -n $MININET_DIR/mininet/util/colorfilters $HOME/.wireshark/ || true + [ -f $MININET_DIR/mininet/util/colorfilters ] && cp -n $MININET_DIR/mininet/util/colorfilters $HOME/.config/wireshark/ || true echo "Checking Wireshark version" - WSVER=`wireshark -v | egrep -o '[0-9\.]+' | head -1` - if version_ge $WSVER 1.12; then + WSVER=`(wireshark -v 2>/dev/null || tshark -v 2>/dev/null || true) | grep -i -E 'wireshark|tshark' | egrep -o '[0-9\.]+' | head -1` + if [ -n "$WSVER" ] && version_ge "$WSVER" 1.12; then echo "Wireshark version $WSVER >= 1.12 - returning" return + elif which wireshark &>/dev/null || which tshark &>/dev/null; then + echo "Wireshark/TShark is already installed and modern versions include OpenFlow dissectors natively - returning" + return fi echo "Cloning LoxiGen and building openflow.lua dissector" cd $BUILD_DIR - git clone https://github.com/floodlight/loxigen.git + if [ ! -d "loxigen" ]; then + git clone https://github.com/floodlight/loxigen.git + fi cd loxigen make wireshark # Copy into plugin directory # libwireshark0/ on 11.04; libwireshark1/ on later WSDIR=`find /usr/lib -type d -name 'libwireshark*' | head -1` - WSPLUGDIR=$WSDIR/plugins/ - PLUGIN=loxi_output/wireshark/openflow.lua - sudo cp $PLUGIN $WSPLUGDIR - echo "Copied openflow plugin $PLUGIN to $WSPLUGDIR" + if [ -n "$WSDIR" ]; then + WSPLUGDIR=$WSDIR/plugins/ + PLUGIN=loxi_output/wireshark/openflow.lua + sudo cp $PLUGIN $WSPLUGDIR + echo "Copied openflow plugin $PLUGIN to $WSPLUGDIR" + fi cd $BUILD_DIR } diff --git a/util/openflow-patches/gcc-glibc.patch b/util/openflow-patches/gcc-glibc.patch new file mode 100644 index 0000000..1febab7 --- /dev/null +++ b/util/openflow-patches/gcc-glibc.patch @@ -0,0 +1,88 @@ +diff --git a/lib/backtrace.c b/lib/backtrace.c +index 5b61ffe..f77e489 100644 +--- a/lib/backtrace.c ++++ b/lib/backtrace.c +@@ -123,6 +123,6 @@ backtrace_capture(struct backtrace *bt) + } + bt->n_frames = n; + #else +- bt->n_frames = backtrace(bt->frames, BACKTRACE_MAX_FRAMES); ++ bt->n_frames = backtrace((void **)bt->frames, BACKTRACE_MAX_FRAMES); + #endif + } +diff --git a/lib/flow.c b/lib/flow.c +index 523eff0..4a1bf7b 100644 +--- a/lib/flow.c ++++ b/lib/flow.c +@@ -44,11 +44,10 @@ + #include "vlog.h" + #define THIS_MODULE VLM_flow + +-static struct arp_header * ++static struct arp_eth_header * + pull_arp(struct ofpbuf *packet) + { + if (packet->size >= ARP_ETH_HEADER_LEN) { +- struct arp_eth_header *arp = packet->data; + return ofpbuf_pull(packet, ARP_ETH_HEADER_LEN); + } + return NULL; +diff --git a/lib/socket-util.c b/lib/socket-util.c +index c7b5d6d..5b3d602 100644 +--- a/lib/socket-util.c ++++ b/lib/socket-util.c +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + #include + #include + #include "fatal-signal.h" +diff --git a/lib/stp.c b/lib/stp.c +index b638311..b81ae53 100644 +--- a/lib/stp.c ++++ b/lib/stp.c +@@ -34,6 +34,7 @@ + /* Based on sample implementation in 802.1D-1998. Above copyright and license + * applies to all modifications. */ + ++#include + #include "stp.h" + #include + #include +diff --git a/lib/util.c b/lib/util.c +index 21cc28d..1f341b1 100644 +--- a/lib/util.c ++++ b/lib/util.c +@@ -138,6 +138,7 @@ xasprintf(const char *format, ...) + return s; + } + ++#ifndef HAVE_STRLCPY + void + strlcpy(char *dst, const char *src, size_t size) + { +@@ -148,6 +149,7 @@ strlcpy(char *dst, const char *src, size_t size) + dst[n_copy] = '\0'; + } + } ++#endif + + void + ofp_fatal(int err_no, const char *format, ...) +diff --git a/lib/util.h b/lib/util.h +index fde681f..dc4e71f 100644 +--- a/lib/util.h ++++ b/lib/util.h +@@ -34,6 +34,10 @@ + #ifndef UTIL_H + #define UTIL_H 1 + ++#if HAVE_CONFIG_H ++#include ++#endif ++ + #include + #include + #include