tcp: use const argument in the TCP hostcache KPI

The hostcache can't modify tcpcb, inpcb or connection info.
This commit is contained in:
Gleb Smirnoff 2024-11-20 16:30:42 -08:00
parent 09000cc133
commit b80c06cc0a
2 changed files with 12 additions and 11 deletions

View File

@ -146,7 +146,7 @@ VNET_DEFINE_STATIC(struct tcp_hostcache, tcp_hostcache);
VNET_DEFINE_STATIC(struct callout, tcp_hc_callout); VNET_DEFINE_STATIC(struct callout, tcp_hc_callout);
#define V_tcp_hc_callout VNET(tcp_hc_callout) #define V_tcp_hc_callout VNET(tcp_hc_callout)
static struct hc_metrics *tcp_hc_lookup(struct in_conninfo *); static struct hc_metrics *tcp_hc_lookup(const struct in_conninfo *);
static int sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS); static int sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS);
static int sysctl_tcp_hc_histo(SYSCTL_HANDLER_ARGS); static int sysctl_tcp_hc_histo(SYSCTL_HANDLER_ARGS);
static int sysctl_tcp_hc_purgenow(SYSCTL_HANDLER_ARGS); static int sysctl_tcp_hc_purgenow(SYSCTL_HANDLER_ARGS);
@ -312,7 +312,7 @@ tcp_hc_destroy(void)
* Internal function: compare cache entry to a connection. * Internal function: compare cache entry to a connection.
*/ */
static bool static bool
tcp_hc_cmp(struct hc_metrics *hc_entry, struct in_conninfo *inc) tcp_hc_cmp(struct hc_metrics *hc_entry, const struct in_conninfo *inc)
{ {
if (inc->inc_flags & INC_ISIPV6) { if (inc->inc_flags & INC_ISIPV6) {
@ -334,7 +334,7 @@ tcp_hc_cmp(struct hc_metrics *hc_entry, struct in_conninfo *inc)
* On success returns in SMR section. * On success returns in SMR section.
*/ */
static struct hc_metrics * static struct hc_metrics *
tcp_hc_lookup(struct in_conninfo *inc) tcp_hc_lookup(const struct in_conninfo *inc)
{ {
struct hc_head *hc_head; struct hc_head *hc_head;
struct hc_metrics *hc_entry; struct hc_metrics *hc_entry;
@ -371,7 +371,8 @@ tcp_hc_lookup(struct in_conninfo *inc)
* a value is not set. * a value is not set.
*/ */
void void
tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite) tcp_hc_get(const struct in_conninfo *inc,
struct hc_metrics_lite *hc_metrics_lite)
{ {
struct hc_metrics *hc_entry; struct hc_metrics *hc_entry;
@ -410,7 +411,7 @@ tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite)
* set. * set.
*/ */
uint32_t uint32_t
tcp_hc_getmtu(struct in_conninfo *inc) tcp_hc_getmtu(const struct in_conninfo *inc)
{ {
struct hc_metrics *hc_entry; struct hc_metrics *hc_entry;
uint32_t mtu; uint32_t mtu;
@ -434,7 +435,7 @@ tcp_hc_getmtu(struct in_conninfo *inc)
* Creates a new entry if none was found. * Creates a new entry if none was found.
*/ */
void void
tcp_hc_updatemtu(struct in_conninfo *inc, uint32_t mtu) tcp_hc_updatemtu(const struct in_conninfo *inc, uint32_t mtu)
{ {
struct hc_metrics_lite hcml = { .hc_mtu = mtu }; struct hc_metrics_lite hcml = { .hc_mtu = mtu };
@ -446,7 +447,7 @@ tcp_hc_updatemtu(struct in_conninfo *inc, uint32_t mtu)
* Creates a new entry if none was found. * Creates a new entry if none was found.
*/ */
void void
tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml) tcp_hc_update(const struct in_conninfo *inc, struct hc_metrics_lite *hcml)
{ {
struct hc_head *hc_head; struct hc_head *hc_head;
struct hc_metrics *hc_entry, *hc_prev; struct hc_metrics *hc_entry, *hc_prev;

View File

@ -1486,10 +1486,10 @@ void tcp_hc_init(void);
#ifdef VIMAGE #ifdef VIMAGE
void tcp_hc_destroy(void); void tcp_hc_destroy(void);
#endif #endif
void tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *); void tcp_hc_get(const struct in_conninfo *, struct hc_metrics_lite *);
uint32_t tcp_hc_getmtu(struct in_conninfo *); uint32_t tcp_hc_getmtu(const struct in_conninfo *);
void tcp_hc_updatemtu(struct in_conninfo *, uint32_t); void tcp_hc_updatemtu(const struct in_conninfo *, uint32_t);
void tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *); void tcp_hc_update(const struct in_conninfo *, struct hc_metrics_lite *);
void cc_after_idle(struct tcpcb *tp); void cc_after_idle(struct tcpcb *tp);
extern struct protosw tcp_protosw; /* shared for TOE */ extern struct protosw tcp_protosw; /* shared for TOE */