4040static void
4141tfw_h2_apply_wnd_sz_change (TfwH2Ctx * ctx , long int delta )
4242{
43- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
43+ TfwH2Conn * conn = ctx -> conn ;
4444 TfwStream * stream , * next ;
4545
4646 /*
@@ -71,7 +71,7 @@ static void
7171tfw_h2_apply_settings_entry (TfwH2Ctx * ctx , unsigned short id ,
7272 unsigned int val )
7373{
74- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
74+ TfwH2Conn * conn = ctx -> conn ;
7575 TfwSettings * dest = & ctx -> rsettings ;
7676 long int delta ;
7777
@@ -120,7 +120,7 @@ tfw_h2_apply_settings_entry(TfwH2Ctx *ctx, unsigned short id,
120120int
121121tfw_h2_check_settings_entry (TfwH2Ctx * ctx , unsigned short id , unsigned int val )
122122{
123- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
123+ TfwH2Conn * conn = ctx -> conn ;
124124
125125 assert_spin_locked (& ((TfwConn * )conn )-> sk -> sk_lock .slock );
126126
@@ -163,7 +163,7 @@ tfw_h2_check_settings_entry(TfwH2Ctx *ctx, unsigned short id, unsigned int val)
163163void
164164tfw_h2_save_settings_entry (TfwH2Ctx * ctx , unsigned short id , unsigned int val )
165165{
166- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
166+ TfwH2Conn * conn = ctx -> conn ;
167167
168168 assert_spin_locked (& ((TfwConn * )conn )-> sk -> sk_lock .slock );
169169
@@ -178,7 +178,7 @@ tfw_h2_save_settings_entry(TfwH2Ctx *ctx, unsigned short id, unsigned int val)
178178void
179179tfw_h2_apply_new_settings (TfwH2Ctx * ctx )
180180{
181- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
181+ TfwH2Conn * conn = ctx -> conn ;
182182 unsigned int id ;
183183
184184 assert_spin_locked (& ((TfwConn * )conn )-> sk -> sk_lock .slock );
@@ -204,14 +204,27 @@ tfw_h2_cleanup(void)
204204 tfw_h2_stream_cache_destroy ();
205205}
206206
207+ TfwH2Ctx *
208+ tfw_h2_context_alloc (void )
209+ {
210+ return (TfwH2Ctx * )kzalloc (sizeof (TfwH2Ctx ), GFP_ATOMIC );
211+ }
212+
213+ void
214+ tfw_h2_context_free (TfwH2Ctx * ctx )
215+ {
216+ kfree (ctx );
217+ }
218+
207219int
208- tfw_h2_context_init (TfwH2Ctx * ctx )
220+ tfw_h2_context_init (TfwH2Ctx * ctx , TfwH2Conn * conn )
209221{
210222 TfwStreamQueue * closed_streams = & ctx -> closed_streams ;
211223 TfwStreamQueue * idle_streams = & ctx -> idle_streams ;
212224 TfwSettings * lset = & ctx -> lsettings ;
213225 TfwSettings * rset = & ctx -> rsettings ;
214226
227+ BUG_ON (!conn || conn -> h2 != ctx );
215228 bzero_fast (ctx , sizeof (* ctx ));
216229
217230 ctx -> state = HTTP2_RECV_CLI_START_SEQ ;
@@ -235,6 +248,7 @@ tfw_h2_context_init(TfwH2Ctx *ctx)
235248
236249 lset -> wnd_sz = DEF_WND_SIZE ;
237250 rset -> wnd_sz = DEF_WND_SIZE ;
251+ ctx -> conn = conn ;
238252
239253 return tfw_hpack_init (& ctx -> hpack , HPACK_TABLE_DEF_SIZE );
240254}
255269tfw_h2_conn_terminate_close (TfwH2Ctx * ctx , TfwH2Err err_code , bool close ,
256270 bool attack )
257271{
258- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
272+ TfwH2Conn * conn = ctx -> conn ;
259273
260274 if (tfw_h2_send_goaway (ctx , err_code , attack ) && close )
261275 tfw_connection_close ((TfwConn * )conn , true);
291305tfw_h2_conn_streams_cleanup (TfwH2Ctx * ctx )
292306{
293307 TfwStream * cur , * next ;
294- TfwH2Conn * conn = container_of ( ctx , TfwH2Conn , h2 ) ;
308+ TfwH2Conn * conn = ctx -> conn ;
295309 TfwStreamSched * sched = & ctx -> sched ;
296310
297311 WARN_ON_ONCE (((TfwConn * )conn )-> stream .msg );
413427tfw_h2_req_unlink_stream (TfwHttpReq * req )
414428{
415429 TfwStream * stream ;
416- TfwH2Ctx * ctx = tfw_h2_context_unsafe (req -> conn );
430+ TfwH2Ctx * ctx = tfw_h2_context (req -> conn );
417431
418432 spin_lock (& ctx -> lock );
419433
437451tfw_h2_req_unlink_and_close_stream (TfwHttpReq * req )
438452{
439453 TfwStream * stream ;
440- TfwH2Ctx * ctx = tfw_h2_context_unsafe (req -> conn );
454+ TfwH2Ctx * ctx = tfw_h2_context (req -> conn );
441455
442456 spin_lock (& ctx -> lock );
443457
0 commit comments