l2tpd_packet: add backref for session

I'vnt't found a solution using container_of() to get the connection for a session.
add a direct pointer to have a direct reference. Saves a lot lookups using the connection id every time
This commit is contained in:
Alexander Couzens 2016-10-30 18:05:41 +01:00 committed by Harald Welte
parent 21ee9718d2
commit 47877011c7
4 changed files with 5 additions and 3 deletions

View File

@ -50,6 +50,8 @@ struct l2tpd_connection {
/* A L2TP session within a connection */
struct l2tpd_session {
/* our conncetion */
struct l2tpd_connection *connection;
/* our link into the connection.sessions */
struct llist_head list;
/* local session ID */

View File

@ -95,6 +95,7 @@ l2tpd_sess_alloc(struct l2tpd_connection *conn)
llist_add(&l2s->list, &conn->sessions);
l2s->fsm = osmo_fsm_inst_alloc(&l2tp_ic_fsm, l2s, l2s, LOGL_DEBUG, id_str);
l2s->connection = conn;
return l2s;
}

View File

@ -187,7 +187,7 @@ static void l2tp_ic_s_init(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void l2tp_ic_s_wait_conn(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct l2tpd_session *l2s = (struct l2tpd_session *) fi->priv;
struct l2tpd_connection *l2c = l2tpd_cc_find_by_l_cc_id(l2i, l2s->l_sess_id);
struct l2tpd_connection *l2c = l2s->connection;
switch (event) {
case L2IC_E_RX_ICCN:

View File

@ -451,8 +451,7 @@ int l2tp_tx_altc_rq_superchannel(struct l2tpd_connection *l2c)
int l2tp_tx_ic_rp(struct l2tpd_session *l2s)
{
struct msgb *msg = l2tp_msgb_alloc();
/* FIXME: use pointer instead of this call */
struct l2tpd_connection *l2c = l2tpd_cc_find_by_l_cc_id(l2i, l2s->l_sess_id);
struct l2tpd_connection *l2c = l2s->connection;
msgb_avp_put_msgt(msg, VENDOR_IETF, IETF_CTRLMSG_ICRP);
msgb_avp_put_digest(msg);