On 17.01.20 15:37, Sergey Safarov wrote:
Not strictly related, but if someone is aware or had some experiences
with,  I am curious if "echo 'del 0' > /proc/rtpengine/control" is
really needed because on a system where I forgot to have it in the
scripts (well, was commented), I haven't noticed any issues after
rtpengine restarts.

Could you clarify of correct order rtpengine start?
What is happen if ipables have rule
```
iptables -I INPUT -p udp -j RTPENGINE --id 0
```


AFAIK, if the rule is already in iptables, nothing should happen, all is ok.


And then rtpengine failed to start?


If the rule in iptables doesn't exist, rtpengine starts fine, but is doing user space forwarding, not kernel forwarding. Calls run fine, only that more cpu is used on rtpengine system (and maybe a little bit more delay, but nothing that can be noticed or to worry about) -- cpu usage is still low for couple of hundred active calls (when I tested), so it is not easy to notice always if the rtpengine does user space forwarding or kernel based forwarding. That's why I asked here to see what would be the best way to ensure everything is prepared for kernel based forwarding.

Cheers,
Daniel


Is any issue here?

On Fri, Jan 17, 2020 at 5:30 PM Sergey Safarov <s.safarov@gmail.com> wrote:
Systemd seems to have the "ExecStartPre" option, is it what people use
to ensure the rtpengine kernel module is loaded and iptables rule exists?


yes, that is option
But this command will be executed for Every daemon start.

Any systemd-specific wayt to run a script only once after system boot? I
have seen workarounds on the net for creating like a rc.local service,
but they didn't look to be systemd-native

I can recommend create dedicated systemd unit file "prepare-rtpengine.service"
Like this

[Unit]
Description=prepare rpengine

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/sbin/modprobe xt_RTPENGINE
ExecStart=/usr/sbin/iptables -I INPUT -p udp -j RTPENGINE --id 0
ExecStartPost=ip6tables -I INPUT -p udp -j RTPENGINE --id 0
StandardOutput=syslog
StandardError=syslog

[Install]
RequiredBy=rtpengine.service
WantedBy=basic.target


and then
systemctl enable prepare-rtpengine.service

This will create dependency that will be execute one tme before rtpengine daemon started.


On Fri, Jan 17, 2020 at 5:03 PM Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,

do people here have (implemented) special ways to properly start
rtpengine with kernel forwarding after system reboot?

From rtpengine readme:

"""

A typical start-up sequence including in-kernel forwarding might look
like this:

# this only needs to be one once after system (re-) boot
modprobe xt_RTPENGINE
iptables -I INPUT -p udp -j RTPENGINE --id 0
ip6tables -I INPUT -p udp -j RTPENGINE --id 0

# ensure that the table we want to use doesn't exist - usually needed
after a daemon
# restart, otherwise will error
echo 'del 0' > /proc/rtpengine/control

# start daemon
/usr/sbin/rtpengine --table=0 --interface=10.64.73.31
--interface=2001:db8::4f3:3d \
--listen-ng=127.0.0.1:2223 --tos=184 --pidfile=/run/rtpengine.pid
--no-fallback

"""

I was relying on shell scripts executed on boot time, but now that
systemd is more common, I am looking to see what are
"standard"/"recommended" ways for running additional scripts besides the
start/stop daemon, which makes it also easier to build packages not
worrying about the type of OS and how it can run scripts at startup.

Systemd seems to have the "ExecStartPre" option, is it what people use
to ensure the rtpengine kernel module is loaded and iptables rule exists?

Any systemd-specific wayt to run a script only once after system boot? I
have seen workarounds on the net for creating like a rc.local service,
but they didn't look to be systemd-native, ...

Not strictly related, but if someone is aware or had some experiences
with,  I am curious if "echo 'del 0' > /proc/rtpengine/control" is
really needed because on a system where I forgot to have it in the
scripts (well, was commented), I haven't noticed any issues after
rtpengine restarts.

Cheers,
Daniel

--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com


_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com