Re: [RFC PATCH net-next v0.1 1/1] net: add GeoNetworking protocol
From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-07-23 17:54:28
On Thu, Jul 23, 2026 at 07:12:19PM +0200, Simon Dietz wrote:
quoted
Passing a binary structure as a netlink attribute is not going to fly.More like this (using generic netlink)? static const struct nla_policy gn_coord_policy[GN_COORD_MAX + 1] = { [GN_COORD_LAT] = { .type = NLA_S32 }, [GN_COORD_LON] = { .type = NLA_S32 }, };
It would be good to add some documentation somewhere what this S32 represents. I normally see LAT and LOG represented as floating points. I _think_ i read somewhere in the standard that over the air messages user 1/10 of a degree?
static const struct nla_policy gn_genl_policy[GN_ATTR_MAX + 1] = {
[GN_ATTR_COORD] = NLA_POLICY_NESTED(gn_coord_policy),
};
static int gn_get_position(struct sk_buff *skb, struct genl_info *info)
/* ... */
nest = nla_nest_start(reply_skb, GN_ATTR_COORD);
if (!nest) {
nlmsg_free(reply_skb);
return -EMSGSIZE;
}
if (nla_put_s32(reply_skb, GN_COORD_LAT, val.lat) ||
nla_put_s32(reply_skb, GN_COORD_LON, val.lon)) {
nlmsg_free(reply_skb);
return -EMSGSIZE;
}
nla_nest_end(reply_skb, nest);Is a nest needed? I'm not a netlink expert, but my understanding was you use nests when you have lists, and each member of the list has a collections of attributes. Do you have a list here, or is it just one location.
quoted
This also does not feel correct. Why is location a property of an interface? Can one machines interfaces be in different locations?I would answer: Unfortunately, yes. Consider a 700m long train (which is the upper limit of train length in europe, in US there may be even longer ones). It is one vehicle, but may have at least two gn (wifi) devices, one at the front and one at the back. That is a niche use case but it is one.
O.K, makes sense. Although i would think it is more likely to be two vehicles with some level of coupling.
That of course would make the implementation a bit more difficult because if the position is saved for each device, then the gn address must be passed along with the position so that the kernel is able to map the via netlink passed position to the right device, which affects the kernel / user space interface.
This is the nice thing about netlink. You can additional attributes later, the device the position is applied to. So at the moment you walk all the interfaces and set their position. In the future, if the ifindex attribute is included you only set that one device. This however brings us back to the routing table. If the location is strictly a property of the interface, the routing table is also a property of an interface? Forwarding on the same interface, and forwarding on a different interface are different operations? Does the standard say anything about multi-interface devices? Andrew