Update install script.
This commit is contained in:
@@ -59,6 +59,7 @@ Additionally, here is a list of flags you may pass to this script.
|
|||||||
| --no-install | Build the tool and/or LibXDP without installing them. |
|
| --no-install | Build the tool and/or LibXDP without installing them. |
|
||||||
| --clean | Remove build files for the tool and LibXDP. |
|
| --clean | Remove build files for the tool and LibXDP. |
|
||||||
| --no-static | Do *not* statically link LibXDP and LibBPF object files when building the tool. This makes the build process faster, but you may need to alter your `LD_LIBRARY_PATH` env variable before running the tool and requires LibXDP to be installed on your system already. |
|
| --no-static | Do *not* statically link LibXDP and LibBPF object files when building the tool. This makes the build process faster, but you may need to alter your `LD_LIBRARY_PATH` env variable before running the tool and requires LibXDP to be installed on your system already. |
|
||||||
|
| --objdump | Dumps the XDP/BPF object file using [`llvm-objdump`](https://llvm.org/docs/CommandGuide/llvm-objdump.html) to Assemby into `objdump.asm`. |
|
||||||
| --help | Displays help message. |
|
| --help | Displays help message. |
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
41
install.sh
41
install.sh
@@ -2,6 +2,8 @@
|
|||||||
LIBXDP=0
|
LIBXDP=0
|
||||||
INSTALL=1
|
INSTALL=1
|
||||||
CLEAN=0
|
CLEAN=0
|
||||||
|
OBJDUMP=0
|
||||||
|
HELP=0
|
||||||
STATIC=1
|
STATIC=1
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
@@ -32,17 +34,14 @@ while [[ $# -gt 0 ]]; do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--help)
|
--objdump)
|
||||||
echo "Usage: install.sh [OPTIONS]"
|
OBJDUMP=1
|
||||||
echo
|
|
||||||
echo "Options:"
|
|
||||||
echo " --libxdp Build and install LibXDP before building the tool."
|
|
||||||
echo " --no-install Build the tool and/or LibXDP without installing them."
|
|
||||||
echo " --clean Remove build files for the tool and LibXDP."
|
|
||||||
echo " --no-static Do not statically link LibXDP and LibBPF object files when building the tool and rely on shared libraries (-lbpf and -lxdp flags)."
|
|
||||||
echo " --help Display this help message."
|
|
||||||
|
|
||||||
exit 0
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
--help)
|
||||||
|
HELP=1
|
||||||
|
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@@ -53,6 +52,20 @@ while [[ $# -gt 0 ]]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$HELP" -gt 0 ]; then
|
||||||
|
echo "Usage: install.sh [OPTIONS]"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " --libxdp Build and install LibXDP before building the tool."
|
||||||
|
echo " --no-install Build the tool and/or LibXDP without installing them."
|
||||||
|
echo " --clean Remove build files for the tool and LibXDP."
|
||||||
|
echo " --no-static Do not statically link LibXDP and LibBPF object files when building the tool and rely on shared libraries (-lbpf and -lxdp flags)."
|
||||||
|
echo " --objdump Dumps the XDP/BPF object file using 'llvm-objdump' to Assemby into 'objdump.asm'."
|
||||||
|
echo " --help Display this help message."
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$CLEAN" -gt 0 ]; then
|
if [ "$CLEAN" -gt 0 ]; then
|
||||||
if [ "$LIBXDP" -gt 0 ]; then
|
if [ "$LIBXDP" -gt 0 ]; then
|
||||||
echo "Cleaning LibXDP..."
|
echo "Cleaning LibXDP..."
|
||||||
@@ -67,6 +80,14 @@ if [ "$CLEAN" -gt 0 ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$OBJDUMP" -gt 0 ]; then
|
||||||
|
echo "Dumping object file..."
|
||||||
|
|
||||||
|
./scripts/objdump.sh
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$LIBXDP" -gt 0 ]; then
|
if [ "$LIBXDP" -gt 0 ]; then
|
||||||
echo "Building LibXDP..."
|
echo "Building LibXDP..."
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
// Set IPv4 and IPv6 common variables.
|
// Set IPv4 and IPv6 common variables.
|
||||||
if (eth->h_proto == htons(ETH_P_IPV6))
|
if (eth->h_proto == htons(ETH_P_IPV6))
|
||||||
{
|
{
|
||||||
iph6 = (data + sizeof(struct ethhdr));
|
iph6 = data + sizeof(struct ethhdr);
|
||||||
|
|
||||||
if (unlikely(iph6 + 1 > (struct ipv6hdr *)data_end))
|
if (unlikely(iph6 + 1 > (struct ipv6hdr *)data_end))
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iph = (data + sizeof(struct ethhdr));
|
iph = data + sizeof(struct ethhdr);
|
||||||
|
|
||||||
if (unlikely(iph + 1 > (struct iphdr *)data_end))
|
if (unlikely(iph + 1 > (struct iphdr *)data_end))
|
||||||
{
|
{
|
||||||
@@ -152,7 +152,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
{
|
{
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
// Scan TCP header.
|
// Scan TCP header.
|
||||||
tcph = (data + sizeof(struct ethhdr) + sizeof(struct ipv6hdr));
|
tcph = data + sizeof(struct ethhdr) + sizeof(struct ipv6hdr);
|
||||||
|
|
||||||
// Check TCP header.
|
// Check TCP header.
|
||||||
if (unlikely(tcph + 1 > (struct tcphdr *)data_end))
|
if (unlikely(tcph + 1 > (struct tcphdr *)data_end))
|
||||||
@@ -170,7 +170,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
|
|
||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
// Scan UDP header.
|
// Scan UDP header.
|
||||||
udph = (data + sizeof(struct ethhdr) + sizeof(struct ipv6hdr));
|
udph = data + sizeof(struct ethhdr) + sizeof(struct ipv6hdr);
|
||||||
|
|
||||||
// Check TCP header.
|
// Check TCP header.
|
||||||
if (unlikely(udph + 1 > (struct udphdr *)data_end))
|
if (unlikely(udph + 1 > (struct udphdr *)data_end))
|
||||||
@@ -188,7 +188,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
|
|
||||||
case IPPROTO_ICMPV6:
|
case IPPROTO_ICMPV6:
|
||||||
// Scan ICMPv6 header.
|
// Scan ICMPv6 header.
|
||||||
icmp6h = (data + sizeof(struct ethhdr) + sizeof(struct ipv6hdr));
|
icmp6h = data + sizeof(struct ethhdr) + sizeof(struct ipv6hdr);
|
||||||
|
|
||||||
// Check ICMPv6 header.
|
// Check ICMPv6 header.
|
||||||
if (unlikely(icmp6h + 1 > (struct icmp6hdr *)data_end))
|
if (unlikely(icmp6h + 1 > (struct icmp6hdr *)data_end))
|
||||||
@@ -207,7 +207,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
{
|
{
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
// Scan TCP header.
|
// Scan TCP header.
|
||||||
tcph = (data + sizeof(struct ethhdr) + (iph->ihl * 4));
|
tcph = data + sizeof(struct ethhdr) + (iph->ihl * 4);
|
||||||
|
|
||||||
// Check TCP header.
|
// Check TCP header.
|
||||||
if (unlikely(tcph + 1 > (struct tcphdr *)data_end))
|
if (unlikely(tcph + 1 > (struct tcphdr *)data_end))
|
||||||
@@ -225,7 +225,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
|
|
||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
// Scan UDP header.
|
// Scan UDP header.
|
||||||
udph = (data + sizeof(struct ethhdr) + (iph->ihl * 4));
|
udph = data + sizeof(struct ethhdr) + (iph->ihl * 4);
|
||||||
|
|
||||||
// Check TCP header.
|
// Check TCP header.
|
||||||
if (unlikely(udph + 1 > (struct udphdr *)data_end))
|
if (unlikely(udph + 1 > (struct udphdr *)data_end))
|
||||||
@@ -243,7 +243,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
|
|
||||||
case IPPROTO_ICMP:
|
case IPPROTO_ICMP:
|
||||||
// Scan ICMP header.
|
// Scan ICMP header.
|
||||||
icmph = (data + sizeof(struct ethhdr) + (iph->ihl * 4));
|
icmph = data + sizeof(struct ethhdr) + (iph->ihl * 4);
|
||||||
|
|
||||||
// Check ICMP header.
|
// Check ICMP header.
|
||||||
if (unlikely(icmph + 1 > (struct icmphdr *)data_end))
|
if (unlikely(icmph + 1 > (struct icmphdr *)data_end))
|
||||||
|
|||||||
Reference in New Issue
Block a user