-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scripts: replace scripts required for using socket pktio
When using linux interfaces as socket pktios we need to block access to those interfaces for applications and some functions of Linux network stack (ping, etc.). Signed-off-by: Bogdan Pricope <[email protected]> Reviewed-by: Matias Elo <[email protected]>
- Loading branch information
1 parent
ed2680e
commit 03dba93
Showing
14 changed files
with
72 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Use this script to block access to a linux interface for other | ||
# applications before it is utilized as a socket pktio, in OFP | ||
# example applications. | ||
|
||
# Check arguments | ||
if [ "$#" -ne 1 ]; then | ||
echo "Error: Invalid number of parameters." | ||
echo "Usage:" | ||
echo " "${0}" <interface_name>" | ||
exit 1 | ||
fi | ||
|
||
linux_intf=${1} | ||
ifconfig $linux_intf &> /dev/null | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Invalid interface '"$linux_intf"'." | ||
exit 1 | ||
fi | ||
|
||
# Check rights | ||
if [ "$EUID" -ne 0 ]; then | ||
echo "Error: Script must be executed with superuser rights." | ||
exit 1 | ||
fi | ||
|
||
# Set iptables: append drop rules | ||
iptables -A FORWARD -i $linux_intf -j DROP | ||
iptables -A INPUT -i $linux_intf -j DROP | ||
ip6tables -A FORWARD -i $linux_intf -j DROP | ||
ip6tables -A INPUT -i $linux_intf -j DROP | ||
|
||
# Disable arp | ||
ifconfig $linux_intf -arp | ||
|
||
# Flush addresses | ||
ip addr flush dev $linux_intf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Use this script to restore access to a linux interface for other | ||
# applications after it was blocked with ofp_linux_interface_acquire.sh. | ||
|
||
# Check arguments | ||
if [ "$#" -ne 1 ]; then | ||
echo "Error: Invalid number of parameters." | ||
echo "Usage:" | ||
echo " "${0}" <interface_name>" | ||
exit 1 | ||
fi | ||
|
||
linux_intf=${1} | ||
ifconfig $linux_intf &> /dev/null | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Invalid interface '"$linux_intf"'." | ||
exit 1 | ||
fi | ||
|
||
# Check rights | ||
if [ "$EUID" -ne 0 ]; then | ||
echo "Error: Script must be executed with superuser rights." | ||
exit 1 | ||
fi | ||
|
||
# Set iptables: delete drop rules | ||
iptables -D FORWARD -i $linux_intf -j DROP | ||
iptables -D INPUT -i $linux_intf -j DROP | ||
ip6tables -D FORWARD -i $linux_intf -j DROP | ||
ip6tables -D INPUT -i $linux_intf -j DROP | ||
|
||
# Enable arp | ||
ifconfig $linux_intf arp |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.