Page MenuHomeFreeBSD

ifconfig: Add gre netlink support
Changes PlannedPublic

Authored by pouria on Thu, Feb 19, 10:58 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 21, 4:59 AM
Unknown Object (File)
Sat, Feb 21, 4:17 AM
Subscribers

Details

Reviewers
glebius
Group Reviewers
network
Summary

Implement netlink support for gre in ifconfig

Test Plan

See D55363

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 70771
Build 67654: arc lint + arc unit

Event Timeline

This revision is not ready and created to discuss about snl_read_reply_code() with @glebius (see more in D55174).

sbin/ifconfig/ifgre.c
110–132

Also, we have to add IFLA_LINKINFO parsers in every ifconfig modules to be able to access the IFLA_ driver specific data (same in geneve).
Any idea to avoid it?
I can work on somehow moving these into ifconfig_netlink.c to avoid repetition, if other solutions are not exists yet.

148

Also, I hate that I have to do this comparison in order to stop running status functions for other drivers.
Same thing happened to me in geneve (D55184) and the reseaon for it is the for loop inside the af_other_status() function in sbin/ifconfig.c.

161

@glebius
I used snl_read_reply_code here intentionally to continue our discussion on snl_read_reply_code().
If the intended behavior of netlink is to respond with NLMSG_ERROR with error equal to 0,
why it returns NL_RTM_NEWLINK (16) here?

Steps to reproduce:
create a gre interface:

ifconfig gre0 create

then to debug:

gdb --args ifconfig gre0
(gdb) br gre_status_nl
Breakpoint 1 at 0x2cbb6: file /usr/src/sbin/ifconfig/ifgre.c, line 145.
(gdb) run
Starting program: /sbin/ifconfig gre0
gre0: flags=8050<POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1476
options=80000<LINKSTATE>
tunnel inet 127.0.0.1 --> 127.0.0.2
groups: gre

Breakpoint 1, gre_status_nl (ctx=0x7fffffffe4b8)
at /usr/src/sbin/ifconfig/ifgre.c:145
145             struct snl_errmsg_data errmsg = {};
(gdb) n
148             if (strncmp(ctx->ifname, "gre", sizeof("gre") - 1) != 0)
(gdb)
148             if (strncmp(ctx->ifname, "gre", sizeof("gre") - 1) != 0)
(gdb)
151             snl_init_writer(ctx->io_ss, &nw);
(gdb)
152             hdr = snl_create_msg_request(&nw, NL_RTM_GETLINK);
(gdb)
153             hdr->nlmsg_flags |= NLM_F_DUMP;
(gdb)
154             snl_reserve_msg_object(&nw, struct ifinfomsg);
(gdb)
155             snl_add_msg_attr_string(&nw, IFLA_IFNAME, ctx->ifname);
(gdb)
157             hdr = snl_finalize_msg(&nw);
(gdb)
158             if (hdr == NULL || !snl_send_message(ctx->io_ss, hdr))
(gdb)
161             if (!snl_read_reply_code(ctx->io_ss, hdr->nlmsg_seq, &errmsg))
(gdb) s
snl_read_reply_code (ss=0x7fffffffe450, nlmsg_seq=3, e=e@entry=0x7fffffffe340)
at /usr/include/netlink/netlink_snl.h:994
994             struct nlmsghdr *hdr = snl_read_reply(ss, nlmsg_seq);
(gdb) n
998             } else if (hdr->nlmsg_type == NLMSG_ERROR) {
(gdb) p hdr->nlmsg_type
$1 = 16
247

Also, I don't like to parse whole data structure of driver to fetch specific member.
Alternative is ugly too, and we have to write another parser (in which adds another duplicated ~20 lines) to reduce driver overhead and fetch specific information.
Any idea?