1

I have developed a daemon program which can get all up interfaces and print their names and other properties. It works fine when my system is running, but failed to list these interfaces after restarting my device(this will cause my daemon auto-start). Below are useful informations for your reference.

Environment

device : jetson xavier nx
system : ubuntu 18.04 - aarch64
network : eth0 - AF_PACKET, AF_INET, AF_INET6
          # eth0 with static ipv4 address 172.18.0.3
          # and there are other interfaces not listed

Custom Service file

[Unit]
Description=test
Wants=network-online.target
After=network.target network-online.target

[Service]
type=forking
ExecStart=/opt/test
Restart=always

[Install]
WantedBy=multi-user.target

Get interfaces by getifaddrs

getifaddrs(&ifaddr);
for(struct ifaddrs *ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
  // some needed valid checking codes here
  printf("Found interfaces %-8s %d\n",ifa->ifa_name,ifa->ifa_addr->sa_family);
}

I expecting the result should contains eth0 2, means AF_INET, but I can only get eth0 17, means AF_PACKET.

I have tried following things respectively:

  1. solutions from this and other posts
  2. add ExecStartPre=/bin/sleep 30 before line ExecStart=/opt/test within service file

and the first doesn't work, the second works fine but I don't think it gets the root of the problem.

So, in short, what causes my daemon program not getting expected interface? How to correct it?

Please don't hesitate to ask for more information.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.