At plenty of places we have access to an address family which may
include some custom addresses but we cannot simply convert them to
the real families without performing some random protocol lookups.
Let's simply add a proto_fam table like we have for the protocols.
The protocols could even be indexed there, but for now it's not worth
it.
/* [AF][sock_dgram][ctrl_dgram] */
extern struct protocol *__protocol_by_family[AF_CUST_MAX][PROTO_NUM_TYPES][2];
+extern const struct proto_fam *__proto_fam_by_family[AF_CUST_MAX];
__decl_thread(extern HA_SPINLOCK_T proto_lock);
/* Registers the protocol <proto> */
return NULL;
}
+/* returns the proto_fam that matches ss_family. This supports custom address
+ * families so it is suitable for use with ss_family as found in various config
+ * element addresses.
+ */
+static inline const struct proto_fam *proto_fam_lookup(int ss_family)
+{
+ if (ss_family >= 0 && ss_family < AF_CUST_MAX)
+ return __proto_fam_by_family[ss_family];
+ return NULL;
+}
+
#endif /* _HAPROXY_PROTOCOL_H */
/*
/* List head of all registered protocols */
static struct list protocols = LIST_HEAD_INIT(protocols);
struct protocol *__protocol_by_family[AF_CUST_MAX][PROTO_NUM_TYPES][2] __read_mostly = { };
+const struct proto_fam *__proto_fam_by_family[AF_CUST_MAX] = { };
/* This is the global spinlock we may need to register/unregister listeners or
* protocols. Its main purpose is in fact to serialize the rare stop/deinit()
__protocol_by_family[sock_family]
[proto->proto_type]
[proto->xprt_type == PROTO_TYPE_DGRAM] = proto;
+ __proto_fam_by_family[sock_family] = proto->fam;
HA_SPIN_UNLOCK(PROTO_LOCK, &proto_lock);
}