@@ -195,14 +195,17 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
195195 get_random_bytes (& random_seqno , sizeof (random_seqno ));
196196 atomic_set (& hard_iface -> bat_iv .ogm_seqno , random_seqno );
197197
198- hard_iface -> bat_iv .ogm_buff_len = BATADV_OGM_HLEN ;
199- ogm_buff = kmalloc (hard_iface -> bat_iv .ogm_buff_len , GFP_ATOMIC );
198+ hard_iface -> bat_iv .ogm_buff .len = BATADV_OGM_HLEN ;
199+ hard_iface -> bat_iv .ogm_buff .capacity = BATADV_OGM_HLEN ;
200+ hard_iface -> bat_iv .ogm_buff .header_length = BATADV_OGM_HLEN ;
201+
202+ ogm_buff = kmalloc (hard_iface -> bat_iv .ogm_buff .capacity , GFP_ATOMIC );
200203 if (!ogm_buff ) {
201204 mutex_unlock (& hard_iface -> bat_iv .ogm_buff_mutex );
202205 return - ENOMEM ;
203206 }
204207
205- hard_iface -> bat_iv .ogm_buff = ogm_buff ;
208+ hard_iface -> bat_iv .ogm_buff . buf = ogm_buff ;
206209
207210 batadv_ogm_packet = (struct batadv_ogm_packet * )ogm_buff ;
208211 batadv_ogm_packet -> packet_type = BATADV_IV_OGM ;
@@ -221,8 +224,9 @@ static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
221224{
222225 mutex_lock (& hard_iface -> bat_iv .ogm_buff_mutex );
223226
224- kfree (hard_iface -> bat_iv .ogm_buff );
225- hard_iface -> bat_iv .ogm_buff = NULL ;
227+ kfree (hard_iface -> bat_iv .ogm_buff .buf );
228+ memset (& hard_iface -> bat_iv .ogm_buff , 0 ,
229+ sizeof (hard_iface -> bat_iv .ogm_buff ));
226230
227231 mutex_unlock (& hard_iface -> bat_iv .ogm_buff_mutex );
228232
@@ -236,7 +240,7 @@ static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface)
236240
237241 mutex_lock (& hard_iface -> bat_iv .ogm_buff_mutex );
238242
239- ogm_buff = hard_iface -> bat_iv .ogm_buff ;
243+ ogm_buff = hard_iface -> bat_iv .ogm_buff . buf ;
240244 if (!ogm_buff )
241245 goto unlock ;
242246
@@ -258,7 +262,7 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
258262
259263 mutex_lock (& hard_iface -> bat_iv .ogm_buff_mutex );
260264
261- ogm_buff = hard_iface -> bat_iv .ogm_buff ;
265+ ogm_buff = hard_iface -> bat_iv .ogm_buff . buf ;
262266 if (!ogm_buff )
263267 goto unlock ;
264268
@@ -796,10 +800,9 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface)
796800static void batadv_iv_ogm_schedule_buff (struct batadv_hard_iface * hard_iface )
797801{
798802 struct batadv_priv * bat_priv = netdev_priv (hard_iface -> mesh_iface );
799- unsigned char * * ogm_buff = & hard_iface -> bat_iv .ogm_buff ;
803+ struct batadv_ogm_buf * ogm_buff = & hard_iface -> bat_iv .ogm_buff ;
800804 struct batadv_ogm_packet * batadv_ogm_packet ;
801805 struct batadv_hard_iface * primary_if , * tmp_hard_iface ;
802- int * ogm_buff_len = & hard_iface -> bat_iv .ogm_buff_len ;
803806 struct list_head * iter ;
804807 u32 seqno ;
805808 u16 tvlv_len = 0 ;
@@ -811,7 +814,7 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
811814 lockdep_assert_held (& hard_iface -> bat_iv .ogm_buff_mutex );
812815
813816 /* interface already disabled by batadv_iv_ogm_iface_disable */
814- if (!* ogm_buff )
817+ if (!ogm_buff -> buf )
815818 return ;
816819
817820 /* the interface gets activated here to avoid race conditions between
@@ -830,9 +833,7 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
830833 * appended as it may alter the tt tvlv container
831834 */
832835 batadv_tt_local_commit_changes (bat_priv );
833- ret = batadv_tvlv_container_ogm_append (bat_priv , ogm_buff ,
834- ogm_buff_len ,
835- BATADV_OGM_HLEN );
836+ ret = batadv_tvlv_container_ogm_append (bat_priv , ogm_buff );
836837 if (ret < 0 ) {
837838 reschedule = true;
838839 goto out ;
@@ -841,7 +842,7 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
841842 tvlv_len = ret ;
842843 }
843844
844- batadv_ogm_packet = ( struct batadv_ogm_packet * )( * ogm_buff ) ;
845+ batadv_ogm_packet = ogm_buff -> buf ;
845846 batadv_ogm_packet -> tvlv_len = htons (tvlv_len );
846847
847848 /* change sequence number to network order */
@@ -857,7 +858,7 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
857858 /* OGMs from secondary interfaces are only scheduled on their
858859 * respective interfaces.
859860 */
860- scheduled = batadv_iv_ogm_queue_add (bat_priv , * ogm_buff , * ogm_buff_len ,
861+ scheduled = batadv_iv_ogm_queue_add (bat_priv , ogm_buff -> buf , ogm_buff -> len ,
861862 hard_iface , hard_iface , 1 , send_time );
862863 if (!scheduled )
863864 reschedule = true;
@@ -873,8 +874,8 @@ static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
873874 if (!kref_get_unless_zero (& tmp_hard_iface -> refcount ))
874875 continue ;
875876
876- scheduled = batadv_iv_ogm_queue_add (bat_priv , * ogm_buff ,
877- * ogm_buff_len , hard_iface ,
877+ scheduled = batadv_iv_ogm_queue_add (bat_priv , ogm_buff -> buf ,
878+ ogm_buff -> len , hard_iface ,
878879 tmp_hard_iface , 1 , send_time );
879880 batadv_hardif_put (tmp_hard_iface );
880881
0 commit comments