examples: rtnl: fix rtnl-link-dump* extra header
PATCH 1/1 examples: rtnl: fix rtnl-link-dump* extra header
RTM_GETLINK takes an ifinfomsg, not a rtgenmsg header, so use the correct type.
Als fix the family to AF_UNSPEC, as this is what is effectively requested.
This just happened to work as rtgenmsg::rtgen_family aliases ifinfomsg::ifi_family, and the kernel only checks the family for PF_BRIDGE or not.
Signed-off-by Jonas Gorski <[email protected]>
--- examples/rtnl/rtnl-link-dump.c | 6 +++--- examples/rtnl/rtnl-link-dump2.c | 6 +++--- examples/rtnl/rtnl-link-dump3.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
examples/rtnl/rtnl-link-dump.c +3 -3
@@ -84,16 +84,16 @@ int main(void)char buf[MNL_SOCKET_DUMP_SIZE ];unsigned int seq, portid;struct mnl_socket *nl; +struct ifinfomsg *ifm;struct nlmsghdr *nlh; -struct rtgenmsg *rt;int ret; nlh =mnl_nlmsg_put_header (buf); nlh->nlmsg_type =RTM_GETLINK ; nlh->nlmsg_flags =NLM_F_REQUEST |NLM_F_DUMP ; nlh->nlmsg_seq = seq =time (NULL ); - rt =mnl_nlmsg_put_extra_header (nlh,sizeof (struct rtgenmsg )); - rt->rtgen_family =AF_PACKET ; + ifm =mnl_nlmsg_put_extra_header (nlh,sizeof (struct ifinfomsg )); + ifm->ifi_family =AF_UNSPEC ; nl =mnl_socket_open (NETLINK_ROUTE );if (nl ==NULL ) {
examples/rtnl/rtnl-link-dump2.c +3 -3
@@ -57,16 +57,16 @@ int main(void)char buf[MNL_SOCKET_DUMP_SIZE ];unsigned int seq, portid;struct mnl_socket *nl; +struct ifinfomsg *ifm;struct nlmsghdr *nlh; -struct rtgenmsg *rt;int ret; nlh =mnl_nlmsg_put_header (buf); nlh->nlmsg_type =RTM_GETLINK ; nlh->nlmsg_flags =NLM_F_REQUEST |NLM_F_DUMP ; nlh->nlmsg_seq = seq =time (NULL ); - rt =mnl_nlmsg_put_extra_header (nlh,sizeof (struct rtgenmsg )); - rt->rtgen_family =AF_PACKET ; + ifm =mnl_nlmsg_put_extra_header (nlh,sizeof (struct ifinfomsg )); + ifm->ifi_family =AF_UNSPEC ; nl =mnl_socket_open (NETLINK_ROUTE );if (nl ==NULL ) {
examples/rtnl/rtnl-link-dump3.c +3 -3
@@ -57,16 +57,16 @@ int main(void)char buf[MNL_SOCKET_DUMP_SIZE ];unsigned int seq, portid;struct mnl_socket *nl; +struct ifinfomsg *ifm;struct nlmsghdr *nlh; -struct rtgenmsg *rt;int ret; nlh =mnl_nlmsg_put_header (buf); nlh->nlmsg_type =RTM_GETLINK ; nlh->nlmsg_flags =NLM_F_REQUEST |NLM_F_DUMP ; nlh->nlmsg_seq = seq =time (NULL ); - rt =mnl_nlmsg_put_extra_header (nlh,sizeof (struct rtgenmsg )); - rt->rtgen_family =AF_PACKET ; + ifm =mnl_nlmsg_put_extra_header (nlh,sizeof (struct ifinfomsg )); + ifm->ifi_family =AF_UNSPEC ; nl =mnl_socket_open (NETLINK_ROUTE );if (nl ==NULL ) {
Signature · 1 line
2.54.0