Sending pcap file via packetgen dpdk - dpdk

Sending a pcap file on port 0. I get the following error. Any fix would be appreciated!
The command used is:
sudo ./app/x86_64-native-linuxapp-gcc/pktgen -c 0X01 -n 1 --file-prefix=pg -w 4:00.1 -- -m 1.0 -T -P -s 0:~/Downloads/bigFlows.pcap

There are 2 obvious reasons for the failure.
Number of CPU cores for pktgen to work is 1 + number of ports in use
you have extra argument in comamnd executed in pktgen.
Checking the link, it show the command used is sudo ./app/x86_64-native-linuxapp-gcc/pktgen -c 0X01 -n 1 --file-prefix=pg -w 4:00.1 -- -m 1.0 -T -P -s 0:[~/Downloads/bigFlows.pcap]. You should not sue [] instead use 0:actual path to pcap.
Note: #SaifUllah during the live debug both core and pcap were show cased for you.

Related

Passing valgrind flags from cmake

Complementary to this question, how can I pass flags to valgrind from cmake?
# enable valgrind checks
set(CTEST_MEMORYCHECK_TYPE "valgrind")
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
According to the docs, The lines above should work, but after running cmake . + make I get:
$ ctest -T memcheck | grep "Memory Leak\|Defects"
1/1 MemCheck: #1: test ............................. Defects: 1
Memory Leak - 1
When I inspect the DartConfiguration.tcl file I don't see my flag there:
$ sed -n "79,80p" ./DartConfiguration.tcl
MemoryCheckCommand: /usr/local/bin/valgrind
MemoryCheckCommandOptions: # <--- nothing here ...
After manually editing DartConfiguration.tcl everything works fine:
$ sed -i "s/MemoryCheckCommandOptions:/MemoryCheckCommandOptions: --leak-check=no/g" DartConfiguration.tcl
$ ctest -T memcheck | grep "Memory Leak\|Defects"
$ # nothing ( good )
All the details exist in the public repo: https://github.com/OrenGitHub/ValgrindCmake
Particularly, the cmake test pipelines: here and here

Is there a way to run boost::process::child with sudo previlage by passing in the password?

On the terminal I can do something like
echo <password> | sudo -S ping www.google.com -c 3
but I am not sure how I can bring this within the c++ code using boost process.
bp::child(bp::search_path("ping"),"www.google.com -c 3",bp::std_out << output)
this works perfectly fine, but when I try to do something like
bp::child(bp::search_path("echo"),"password","|","sudo -S ping www.google.com -c 3",bp::std_out << output)
it gives an error.
I tried using bp::search_path("sh") to run the shell and pass the command, but this also gives and error saying cannot execute binary executables.
Any help will be really appreciated!
The security remarks to your question are fair. But, I can assume that what you are trying to do should look like this:
bp::child(bp::search_path("/usr/bin/bash"),"-c 'echo <password> | sudo -S ping www.google.com -c 3'",bp::std_out << output)

how to hold xterm during debugging an mpi program?

I run the debugger via
mpirun -n 4 xterm -e gdb -x commands.gdb ./my_mpi_programm
where the file "commands.gdb" just contains the commands
start
continue
The problem is that my 4 xterm immediately close before I get a chance to inspect the error message or do any debugging.
I'm using the latest ubuntu distribution. However, on my friend's old Suse-distribution, xterm is held open.
How can I force the xterms to stay?
EDIT: the "-hold" option doesnt work as well as
mpirun -n 4 xterm -e "gdb -x commands.gdb ./my_mpi_programm;bash"
Try
mpirun -n 4 xterm -e bash -c 'gdb -x commands.gdb ./my_mpi_programm; sleep 60'

Append two new lines before additional text using sed

I've hit a bit of a stumper (for me). I'm attempting to insert two newline characters into the RHEL5 /etc/sysconfig/iptables file during our server build process (using kickstart post-installation scripts).
The specific sed command is:
${SED} -i "/-i lo/ a\
\n\n#Trusted Traffic\n-A INPUT -s 10.153.156.0/25,10.153.174.160/27 -d ${MGTIP} -m state --state NEW -j ACCEPT\n\n#Remote Access\n-A INPUT -s 10.120.80.0/21,10.152.80.0/21,10.153.193.0/24,172.18.1.0/24,${MGTNET}/${NUMBITS} -d ${MGTIP} -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n#Backups\n-A INPUT -s 10.153.147.192/26 -d ${BKPIP} -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n" ${IPTABLES}
This is actually part of a larger script. ${SED}and ${IPTABLES} are already set to the necessary values.
All of the newlines work with the exception of the first two. Or, more accurately, the second of the first two. Even the last two newlines after ACCEPT work. What happens with the first two newlines is that the first works, creating a newline after matching the iptables entry which contains -i lo. The second, however, simply inserts a literal 'n' prior to the #Trusted Traffic text.
It ends up looking like
(snip)
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
n#Trusted Traffic
-A INPUT (snip)
I've tried various methods of ensuring the second newline is inserted. I've used two blank lines instead of \n\n. I've used two newline characters on separate lines, I've used \\n\\n. Everything I've tried so far results in the same outcome: A literal 'n' being inserted instead of a second newline.
Does sed simply not work with two newline characters at the beginning of appended text? Is there a way to make this work that I'm simply ignorant of?
I don't see why it's not working either, but you can do this also with the substitute option instead of append:
${SED} -i "s%-i lo.*%&\n\n#Trusted Traffic\n-A INPUT -s 10.153.156.0/25,10.153.174.160/27 -d ${MGTIP} -m state --state NEW -j ACCEPT\n\n#Remote Access\n-A INPUT -s 10.120.80.0/21,10.152.80.0/21,10.153.193.0/24,172.18.1.0/24,${MGTNET}/${NUMBITS} -d ${MGTIP} -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n#Backups\n-A INPUT -s 10.153.147.192/26 -d ${BKPIP} -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n%" ${IPTABLES}
Interesting, I would have thought that one of your attempted solutions would work, but I am seeing the same behavior. Here is one potential solution:
${SED} -i -e "s/-i lo.*/\0\n\n/" -e "// a\
#Trusted Traffic\n-A INPUT -s 10.153.156.0/25,10.153.174.160/27 -d ${MGTIP} -m state --state NEW -j ACCEPT\n\n#Remote Access\n-A INPUT -s 10.120.80.0/21,10.152.80.0/21,10.153.193.0/24,172.18.1.0/24,${MGTNET}/${NUMBITS} -d ${MGTIP} -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n#Backups\n-A INPUT -s 10.153.147.192/26 -d ${BKPIP} -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n\n" ${IPTABLES}
This works by first appending the two newlines to the end of the previous line, and then doing the append.
Not sure about portability, but try:
${SED} '/-i lo/ a\
\
\
'"#Trusted Traffic\\
-A INPUT -s 10.153.156...
"
This technique works on BSD sed. You can maintain double quotes throughout with:
${SED} "/-i lo/ a\\
\\
\\
#Trusted Traffic\\
-A INPUT -s 10.153.156...
"
In either case, there must be no whitespace between the backslash and the end of the line.

How to run the programe with parameters inside gdb?

Suppose I'm in gdb memcached,but want to run it as memcached -d -u root -m 50 -c 1024 -p 11051.
How to do this?
On the gdb prompt, juste type
run -d -u root -m 50 -c 1024 -p 11051
Alternativerly, you can also use the args parameter:
(gdb) help set args
Set argument list to give program being debugged when it is started.
Follow this command with any number of args, to be passed to the program.
so in your case:
set args -d -u root -m 50 -c 1024 -p 11051
run (or) start