How to run my function in kernel module after pppoe is started?

I have written a kernel module to handle IP messages on device named "pppoe-wan", but I need to load it manually everytime after pppoe is started.
Is there any way to tell sysytem to run a C function in kernel module everytime pppoe actived? Then I can just regist the hook the function.

If you have any ideas (even if it may be helpless), please write it down this topic. Thanks very much!:smile:

Put your shell script in /etc/ppp/ip-up.d, scripts inside this folder will be called after establishing ppp connection.

# When the ppp link comes up, this script is called with the following
# parameters
#       $1      the interface name used by pppd (e.g. pppoe-wan)
#       $2      the tty device name
#       $3      the tty device speed
#       $4      the local IP address for the interface
#       $5      the remote IP address
#       $6      the parameter specified by the 'ipparam' option to pppd

# continue only if interface is "pppoe-wan":
[ "$1" = "pppoe-wan" ] || exit 0

# pass the IP address to some program:
some_program --some-paramater $4

You can also create a script that will be executed once the link has been terminated. This is stored in /etc/ppp/ip-down.d. It can be used to undo anything special that you did in the corresponding /etc/ppp/ip-up.d scripts.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.