Index: route.h =================================================================== RCS file: /cvs/src/sys/net/route.h,v retrieving revision 1.199 diff -u -p -r1.199 route.h --- route.h 26 Apr 2023 19:54:35 -0000 1.199 +++ route.h 10 Nov 2023 15:11:22 -0000 @@ -38,6 +38,10 @@ /* * Locks used to protect struct members in this file: * I immutable after creation + * N net lock + * R art (rtable) lock + * L arp/nd6/etc lock for updates, net lock for reads + * A atomic ops * T rttimer_mtx route timer lists */ @@ -99,37 +103,43 @@ struct rttimer; * preferring the former if available. For each route we infer * the interface to use from the gateway address supplied when * the route was entered. Routes that forward packets through - * gateways are marked so that the output routines know to address the - * gateway rather than the ultimate destination. + * gateways are marked with RTF_GATEWAY so that the output routines + * know to address the gateway rather than the ultimate destination. + * + * How the RT_gw union is used also depends on RTF_GATEWAY. With + * RTF_GATEWAY set, rt_gwroute points at the rtentry for the rt_gateway + * address. If RTF_GATEWAY is not set, rt_cachecnt contains the + * number of RTF_GATEWAY rtentry structs with their rt_gwroute pointing + * at this rtentry. */ struct rtentry { - struct sockaddr *rt_dest; /* destination */ - SRPL_ENTRY(rtentry) rt_next; /* Next multipath entry to our dst. */ - struct sockaddr *rt_gateway; /* value */ - struct ifaddr *rt_ifa; /* the answer: interface addr to use */ - caddr_t rt_llinfo; /* pointer to link level info cache or - to an MPLS structure */ + struct sockaddr *rt_dest; /* [I] destination */ + SRPL_ENTRY(rtentry) rt_next; /* [R] next mpath entry to our dst */ + struct sockaddr *rt_gateway; /* [N] gateway address */ + struct ifaddr *rt_ifa; /* [N] interface addr to use */ + caddr_t rt_llinfo; /* [R] pointer to link level info or + an MPLS structure */ union { - struct rtentry *_nh; /* implied entry for gatewayed routes */ - unsigned int _ref; /* # gatewayed caching this route */ + struct rtentry *_nh; /* [N] rtentry for rt_gateway */ + unsigned int _ref; /* [N] # gateway rtentry refs */ } RT_gw; #define rt_gwroute RT_gw._nh #define rt_cachecnt RT_gw._ref - struct rtentry *rt_parent; /* If cloned, parent of this route. */ + struct rtentry *rt_parent; /* [N] if cloned, parent rtentry */ LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */ struct rt_kmetrics rt_rmx; /* metrics used by rx'ing protocols */ - unsigned int rt_ifidx; /* the answer: interface to use */ - unsigned int rt_flags; /* up/down?, host/net */ - struct refcnt rt_refcnt; /* # held references */ - int rt_plen; /* prefix length */ - uint16_t rt_labelid; /* route label ID */ - uint8_t rt_priority; /* routing priority to use */ + unsigned int rt_ifidx; /* [N] interface to use */ + unsigned int rt_flags; /* [N] up/down?, host/net */ + struct refcnt rt_refcnt; /* [A] # held references */ + int rt_plen; /* [I] prefix length */ + uint16_t rt_labelid; /* [N] route label ID */ + uint8_t rt_priority; /* [N] routing priority to use */ }; -#define rt_use rt_rmx.rmx_pksent -#define rt_expire rt_rmx.rmx_expire -#define rt_locks rt_rmx.rmx_locks -#define rt_mtu rt_rmx.rmx_mtu +#define rt_use rt_rmx.rmx_pksent /* [N] */ +#define rt_expire rt_rmx.rmx_expire /* [N] */ +#define rt_locks rt_rmx.rmx_locks /* [N] */ +#define rt_mtu rt_rmx.rmx_mtu /* [N] */ #endif /* _KERNEL */