ca99a5acc59c8319d3f080349465fd7d72a2ab02
[dragonfly.git] / sys / netproto / atalk / aarp.c
1 /*
2  * Copyright (c) 1990,1991 Regents of The University of Michigan.
3  * All Rights Reserved.
4  *
5  * $FreeBSD: src/sys/netatalk/aarp.c,v 1.12.2.2 2001/06/23 20:43:09 iedowse Exp $
6  * $DragonFly: src/sys/netproto/atalk/aarp.c,v 1.13 2004/08/02 13:22:33 joerg Exp $
7  */
8
9 #include "opt_atalk.h"
10
11 #include <sys/param.h>
12 #include <sys/systm.h>
13 #include <sys/mbuf.h>
14 #include <sys/kernel.h>
15 #include <sys/socket.h>
16 #include <sys/syslog.h>
17
18 #include <sys/thread2.h>
19 #include <sys/msgport2.h>
20
21 #include <net/if.h>
22 #include <net/netisr.h>
23
24 #include <netinet/in.h>
25 #undef s_net
26 #include <netinet/if_ether.h>
27
28 #include "at.h"
29 #include "at_var.h"
30 #include "aarp.h"
31 #include "phase2.h"
32 #include "at_extern.h"
33
34 static void aarptfree( struct aarptab *aat);
35 static void at_aarpinput( struct arpcom *ac, struct mbuf *m);
36
37 #define AARPTAB_BSIZ    9
38 #define AARPTAB_NB      19
39 #define AARPTAB_SIZE    (AARPTAB_BSIZ * AARPTAB_NB)
40 static struct aarptab   aarptab[AARPTAB_SIZE];
41
42 #define AARPTAB_HASH(a) \
43     ((((a).s_net << 8 ) + (a).s_node ) % AARPTAB_NB )
44
45 #define AARPTAB_LOOK(aat,addr) { \
46     int         n; \
47     aat = &aarptab[ AARPTAB_HASH(addr) * AARPTAB_BSIZ ]; \
48     for ( n = 0; n < AARPTAB_BSIZ; n++, aat++ ) \
49         if ( aat->aat_ataddr.s_net == (addr).s_net && \
50              aat->aat_ataddr.s_node == (addr).s_node ) \
51             break; \
52         if ( n >= AARPTAB_BSIZ ) \
53             aat = 0; \
54 }
55
56 #define AARPT_AGE       (60 * 1)
57 #define AARPT_KILLC     20
58 #define AARPT_KILLI     3
59
60 static u_char atmulticastaddr[ 6 ] = {
61     0x09, 0x00, 0x07, 0xff, 0xff, 0xff,
62 };
63
64 u_char  at_org_code[ 3 ] = {
65     0x08, 0x00, 0x07,
66 };
67 u_char  aarp_org_code[ 3 ] = {
68     0x00, 0x00, 0x00,
69 };
70
71 static struct callout_handle aarptimer_ch =
72     CALLOUT_HANDLE_INITIALIZER(&aarptimer_ch);
73
74 static void
75 aarptimer(void *ignored)
76 {
77     struct aarptab      *aat;
78     int                 i, s;
79
80     aarptimer_ch = timeout( aarptimer, (caddr_t)0, AARPT_AGE * hz );
81     aat = aarptab;
82     for ( i = 0; i < AARPTAB_SIZE; i++, aat++ ) {
83         if ( aat->aat_flags == 0 || ( aat->aat_flags & ATF_PERM ))
84             continue;
85         if ( ++aat->aat_timer < (( aat->aat_flags & ATF_COM ) ?
86                 AARPT_KILLC : AARPT_KILLI ))
87             continue;
88         s = splimp();
89         aarptfree( aat );
90         splx( s );
91     }
92 }
93
94 /* 
95  * search through the network addresses to find one that includes
96  * the given network.. remember to take netranges into
97  * consideration.
98  */
99 struct at_ifaddr *
100 at_ifawithnet(struct sockaddr_at  *sat )
101 {
102     struct at_ifaddr    *aa;
103     struct sockaddr_at  *sat2;
104
105         for ( aa = at_ifaddr; aa; aa = aa->aa_next ) {
106                 sat2 = &(aa->aa_addr);
107                 if ( sat2->sat_addr.s_net == sat->sat_addr.s_net ) {
108                         break;
109                 }
110                 if( (aa->aa_flags & AFA_PHASE2 )
111                 && (ntohs(aa->aa_firstnet) <= ntohs(sat->sat_addr.s_net))
112                 && (ntohs(aa->aa_lastnet) >= ntohs(sat->sat_addr.s_net))) {
113                         break;
114                 }
115         }
116         return( aa );
117 }
118
119 static void
120 aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat )
121 {
122     struct mbuf         *m;
123     struct ether_header *eh;
124     struct ether_aarp   *ea;
125     struct at_ifaddr    *aa;
126     struct llc          *llc;
127     struct sockaddr     sa;
128
129     if (( m = m_gethdr( MB_DONTWAIT, MT_DATA )) == NULL ) {
130         return;
131     }
132     m->m_len = sizeof( *ea );
133     m->m_pkthdr.len = sizeof( *ea );
134     MH_ALIGN( m, sizeof( *ea ));
135
136     ea = mtod( m, struct ether_aarp *);
137     bzero((caddr_t)ea, sizeof( *ea ));
138
139     ea->aarp_hrd = htons( AARPHRD_ETHER );
140     ea->aarp_pro = htons( ETHERTYPE_AT );
141     ea->aarp_hln = sizeof( ea->aarp_sha );
142     ea->aarp_pln = sizeof( ea->aarp_spu );
143     ea->aarp_op = htons( AARPOP_REQUEST );
144     bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha,
145             sizeof( ea->aarp_sha ));
146
147     /*
148      * We need to check whether the output ethernet type should
149      * be phase 1 or 2. We have the interface that we'll be sending
150      * the aarp out. We need to find an AppleTalk network on that
151      * interface with the same address as we're looking for. If the
152      * net is phase 2, generate an 802.2 and SNAP header.
153      */
154     if ((aa = at_ifawithnet( sat )) == NULL) {
155         m_freem( m );
156         return;
157     }
158
159     eh = (struct ether_header *)sa.sa_data;
160
161     if ( aa->aa_flags & AFA_PHASE2 ) {
162         bcopy((caddr_t)atmulticastaddr, (caddr_t)eh->ether_dhost,
163                 sizeof( eh->ether_dhost ));
164         eh->ether_type = htons(sizeof(struct llc) + sizeof(struct ether_aarp));
165         M_PREPEND( m, sizeof( struct llc ), MB_WAIT );
166         llc = mtod( m, struct llc *);
167         llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP;
168         llc->llc_control = LLC_UI;
169         bcopy( aarp_org_code, llc->llc_org_code, sizeof( aarp_org_code ));
170         llc->llc_ether_type = htons( ETHERTYPE_AARP );
171
172         bcopy( &AA_SAT( aa )->sat_addr.s_net, ea->aarp_spnet,
173                sizeof( ea->aarp_spnet ));
174         bcopy( &sat->sat_addr.s_net, ea->aarp_tpnet,
175                sizeof( ea->aarp_tpnet ));
176         ea->aarp_spnode = AA_SAT( aa )->sat_addr.s_node;
177         ea->aarp_tpnode = sat->sat_addr.s_node;
178     } else {
179         bcopy(ac->ac_if.if_broadcastaddr, eh->ether_dhost,
180               ac->ac_if.if_addrlen);
181         eh->ether_type = htons( ETHERTYPE_AARP );
182
183         ea->aarp_spa = AA_SAT( aa )->sat_addr.s_node;
184         ea->aarp_tpa = sat->sat_addr.s_node;
185     }
186
187 #ifdef NETATALKDEBUG
188     printf("aarp: sending request for %u.%u\n",
189            ntohs(AA_SAT( aa )->sat_addr.s_net),
190            AA_SAT( aa )->sat_addr.s_node);
191 #endif /* NETATALKDEBUG */
192
193     sa.sa_len = sizeof( struct sockaddr );
194     sa.sa_family = AF_UNSPEC;
195     (*ac->ac_if.if_output)(&ac->ac_if,
196         m, &sa, NULL);  /* XXX NULL should be routing information */
197 }
198
199 int
200 aarpresolve( ac, m, destsat, desten )
201     struct arpcom       *ac;
202     struct mbuf         *m;
203     struct sockaddr_at  *destsat;
204     u_char              *desten;
205 {
206     struct at_ifaddr    *aa;
207     struct aarptab      *aat;
208     int                 s;
209
210     if ( at_broadcast( destsat )) {
211         m->m_flags |= M_BCAST;
212         if ((aa = at_ifawithnet( destsat )) == NULL)  {
213             m_freem( m );
214             return( 0 );
215         }
216         if ( aa->aa_flags & AFA_PHASE2 ) {
217             bcopy( (caddr_t)atmulticastaddr, (caddr_t)desten,
218                     sizeof( atmulticastaddr ));
219         } else {
220             bcopy(ac->ac_if.if_broadcastaddr, desten, ac->ac_if.if_addrlen);
221         }
222         return( 1 );
223     }
224
225     s = splimp();
226     AARPTAB_LOOK( aat, destsat->sat_addr );
227     if ( aat == 0 ) {                   /* No entry */
228         aat = aarptnew( &destsat->sat_addr );
229         if ( aat == 0 ) {
230             panic( "aarpresolve: no free entry" );
231         }
232         aat->aat_hold = m;
233         aarpwhohas( ac, destsat );
234         splx( s );
235         return( 0 );
236     }
237     /* found an entry */
238     aat->aat_timer = 0;
239     if ( aat->aat_flags & ATF_COM ) {   /* entry is COMplete */
240         bcopy( (caddr_t)aat->aat_enaddr, (caddr_t)desten,
241                 sizeof( aat->aat_enaddr ));
242         splx( s );
243         return( 1 );
244     }
245     /* entry has not completed */
246     if ( aat->aat_hold ) {
247         m_freem( aat->aat_hold );
248     }
249     aat->aat_hold = m;
250     aarpwhohas( ac, destsat );
251     splx( s );
252     return( 0 );
253 }
254
255 int
256 aarpintr(struct netmsg *msg)
257 {
258     struct mbuf *m = ((struct netmsg_packet *)msg)->nm_packet;   
259     struct arphdr       *ar;
260     struct arpcom       *ac;
261
262     ac = (struct arpcom *)m->m_pkthdr.rcvif;
263     if ( ac->ac_if.if_flags & IFF_NOARP )
264         goto out;
265
266     if ( m->m_len < sizeof( struct arphdr )) {
267         goto out;
268     }
269
270     ar = mtod( m, struct arphdr *);
271     if ( ntohs( ar->ar_hrd ) != AARPHRD_ETHER ) {
272         goto out;
273     }
274     
275     if ( m->m_len < sizeof( struct arphdr ) + 2 * ar->ar_hln +
276             2 * ar->ar_pln ) {
277         goto out;
278     }
279     
280     switch( ntohs( ar->ar_pro )) {
281     case ETHERTYPE_AT :
282         at_aarpinput( ac, m );
283         goto out2;
284
285     default:
286         break;
287     }
288
289 out:
290     m_freem(m);
291 out2:
292     lwkt_replymsg(&msg->nm_lmsg, 0);
293     return(EASYNC);
294 }
295
296 static void
297 at_aarpinput( struct arpcom *ac, struct mbuf *m)
298 {
299     struct ether_aarp   *ea;
300     struct ifaddr       *ifa;
301     struct at_ifaddr    *aa;
302     struct aarptab      *aat;
303     struct ether_header *eh;
304     struct llc          *llc;
305     struct sockaddr_at  sat;
306     struct sockaddr     sa;
307     struct at_addr      spa, tpa, ma;
308     int                 op;
309     u_short             net;
310
311     ea = mtod( m, struct ether_aarp *);
312
313     /* Check to see if from my hardware address */
314     if ( !bcmp(( caddr_t )ea->aarp_sha, ( caddr_t )ac->ac_enaddr,
315             sizeof( ac->ac_enaddr ))) {
316         m_freem( m );
317         return;
318     }
319
320     op = ntohs( ea->aarp_op );
321     bcopy( ea->aarp_tpnet, &net, sizeof( net ));
322
323     if ( net != 0 ) { /* should be ATADDR_ANYNET? */
324         sat.sat_len = sizeof(struct sockaddr_at);
325         sat.sat_family = AF_APPLETALK;
326         sat.sat_addr.s_net = net;
327         if ((aa = at_ifawithnet( &sat )) == NULL) {
328             m_freem( m );
329             return;
330         }
331         bcopy( ea->aarp_spnet, &spa.s_net, sizeof( spa.s_net ));
332         bcopy( ea->aarp_tpnet, &tpa.s_net, sizeof( tpa.s_net ));
333     } else {
334         /*
335          * Since we don't know the net, we just look for the first
336          * phase 1 address on the interface.
337          */
338         TAILQ_FOREACH(ifa, &ac->ac_if.if_addrhead, ifa_link) {
339             aa = (struct at_ifaddr *)ifa;
340             if ( AA_SAT( aa )->sat_family == AF_APPLETALK &&
341                     ( aa->aa_flags & AFA_PHASE2 ) == 0 ) {
342                 break;
343             }
344         }
345         if ( aa == NULL ) {
346             m_freem( m );
347             return;
348         }
349         tpa.s_net = spa.s_net = AA_SAT( aa )->sat_addr.s_net;
350     }
351
352     spa.s_node = ea->aarp_spnode;
353     tpa.s_node = ea->aarp_tpnode;
354     ma.s_net = AA_SAT( aa )->sat_addr.s_net;
355     ma.s_node = AA_SAT( aa )->sat_addr.s_node;
356
357     /*
358      * This looks like it's from us.
359      */
360     if ( spa.s_net == ma.s_net && spa.s_node == ma.s_node ) {
361         if ( aa->aa_flags & AFA_PROBING ) {
362             /*
363              * We're probing, someone either responded to our probe, or
364              * probed for the same address we'd like to use. Change the
365              * address we're probing for.
366              */
367             untimeout( aarpprobe, ac, aa->aa_ch );
368             wakeup( aa );
369             m_freem( m );
370             return;
371         } else if ( op != AARPOP_PROBE ) {
372             /*
373              * This is not a probe, and we're not probing. This means
374              * that someone's saying they have the same source address
375              * as the one we're using. Get upset...
376              */
377             log( LOG_ERR,
378                     "aarp: duplicate AT address!! %x:%x:%x:%x:%x:%x\n",
379                     ea->aarp_sha[ 0 ], ea->aarp_sha[ 1 ], ea->aarp_sha[ 2 ],
380                     ea->aarp_sha[ 3 ], ea->aarp_sha[ 4 ], ea->aarp_sha[ 5 ]);
381             m_freem( m );
382             return;
383         }
384     }
385
386     AARPTAB_LOOK( aat, spa );
387     if ( aat ) {
388         if ( op == AARPOP_PROBE ) {
389             /*
390              * Someone's probing for spa, dealocate the one we've got,
391              * so that if the prober keeps the address, we'll be able
392              * to arp for him.
393              */
394             aarptfree( aat );
395             m_freem( m );
396             return;
397         }
398
399         bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )aat->aat_enaddr,
400                 sizeof( ea->aarp_sha ));
401         aat->aat_flags |= ATF_COM;
402         if ( aat->aat_hold ) {
403             struct mbuf *mhold = aat->aat_hold;
404             aat->aat_hold = NULL;
405             sat.sat_len = sizeof(struct sockaddr_at);
406             sat.sat_family = AF_APPLETALK;
407             sat.sat_addr = spa;
408             (*ac->ac_if.if_output)( &ac->ac_if, mhold,
409                     (struct sockaddr *)&sat, NULL); /* XXX */
410         }
411     } else if ((tpa.s_net == ma.s_net)
412            && (tpa.s_node == ma.s_node)
413            && (op != AARPOP_PROBE)
414            && ((aat = aarptnew( &spa )) != NULL)) {
415                 bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )aat->aat_enaddr,
416                     sizeof( ea->aarp_sha ));
417                 aat->aat_flags |= ATF_COM;
418     }
419
420     /*
421      * Don't respond to responses, and never respond if we're
422      * still probing.
423      */
424     if ( tpa.s_net != ma.s_net || tpa.s_node != ma.s_node ||
425             op == AARPOP_RESPONSE || ( aa->aa_flags & AFA_PROBING )) {
426         m_freem( m );
427         return;
428     }
429
430     bcopy(( caddr_t )ea->aarp_sha, ( caddr_t )ea->aarp_tha,
431             sizeof( ea->aarp_sha ));
432     bcopy(( caddr_t )ac->ac_enaddr, ( caddr_t )ea->aarp_sha,
433             sizeof( ea->aarp_sha ));
434
435     /* XXX */
436     eh = (struct ether_header *)sa.sa_data;
437     bcopy(( caddr_t )ea->aarp_tha, ( caddr_t )eh->ether_dhost,
438             sizeof( eh->ether_dhost ));
439
440     if ( aa->aa_flags & AFA_PHASE2 ) {
441         eh->ether_type = htons( sizeof( struct llc ) +
442                 sizeof( struct ether_aarp ));
443         M_PREPEND( m, sizeof( struct llc ), MB_DONTWAIT );
444         if ( m == NULL ) {
445             return;
446         }
447         llc = mtod( m, struct llc *);
448         llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP;
449         llc->llc_control = LLC_UI;
450         bcopy( aarp_org_code, llc->llc_org_code, sizeof( aarp_org_code ));
451         llc->llc_ether_type = htons( ETHERTYPE_AARP );
452
453         bcopy( ea->aarp_spnet, ea->aarp_tpnet, sizeof( ea->aarp_tpnet ));
454         bcopy( &ma.s_net, ea->aarp_spnet, sizeof( ea->aarp_spnet ));
455     } else {
456         eh->ether_type = htons( ETHERTYPE_AARP );
457     }
458
459     ea->aarp_tpnode = ea->aarp_spnode;
460     ea->aarp_spnode = ma.s_node;
461     ea->aarp_op = htons( AARPOP_RESPONSE );
462
463     sa.sa_len = sizeof( struct sockaddr );
464     sa.sa_family = AF_UNSPEC;
465     (*ac->ac_if.if_output)( &ac->ac_if, m, &sa, NULL); /* XXX */
466     return;
467 }
468
469 static void
470 aarptfree( struct aarptab *aat)
471 {
472
473     if ( aat->aat_hold )
474         m_freem( aat->aat_hold );
475     aat->aat_hold = NULL;
476     aat->aat_timer = aat->aat_flags = 0;
477     aat->aat_ataddr.s_net = 0;
478     aat->aat_ataddr.s_node = 0;
479 }
480
481     struct aarptab *
482 aarptnew( addr )
483     struct at_addr      *addr;
484 {
485     int                 n;
486     int                 oldest = -1;
487     struct aarptab      *aat, *aato = NULL;
488     static int          first = 1;
489
490     if ( first ) {
491         first = 0;
492         aarptimer_ch = timeout( aarptimer, (caddr_t)0, hz );
493     }
494     aat = &aarptab[ AARPTAB_HASH( *addr ) * AARPTAB_BSIZ ];
495     for ( n = 0; n < AARPTAB_BSIZ; n++, aat++ ) {
496         if ( aat->aat_flags == 0 )
497             goto out;
498         if ( aat->aat_flags & ATF_PERM )
499             continue;
500         if ((int) aat->aat_timer > oldest ) {
501             oldest = aat->aat_timer;
502             aato = aat;
503         }
504     }
505     if ( aato == NULL )
506         return( NULL );
507     aat = aato;
508     aarptfree( aat );
509 out:
510     aat->aat_ataddr = *addr;
511     aat->aat_flags = ATF_INUSE;
512     return( aat );
513 }
514
515
516 void
517 aarpprobe( void *arg )
518 {
519     struct arpcom       *ac = arg;
520     struct mbuf         *m;
521     struct ether_header *eh;
522     struct ether_aarp   *ea;
523     struct ifaddr       *ifa;
524     struct at_ifaddr    *aa;
525     struct llc          *llc;
526     struct sockaddr     sa;
527
528     /*
529      * We need to check whether the output ethernet type should
530      * be phase 1 or 2. We have the interface that we'll be sending
531      * the aarp out. We need to find an AppleTalk network on that
532      * interface with the same address as we're looking for. If the
533      * net is phase 2, generate an 802.2 and SNAP header.
534      */
535     TAILQ_FOREACH(ifa, &ac->ac_if.if_addrhead, ifa_link) {
536         aa = (struct at_ifaddr *)ifa;
537         if ( AA_SAT( aa )->sat_family == AF_APPLETALK &&
538                 ( aa->aa_flags & AFA_PROBING )) {
539             break;
540         }
541     }
542     if ( aa == NULL ) {         /* serious error XXX */
543         printf( "aarpprobe why did this happen?!\n" );
544         return;
545     }
546
547     if ( aa->aa_probcnt <= 0 ) {
548         aa->aa_flags &= ~AFA_PROBING;
549         wakeup( aa );
550         return;
551     } else {
552         aa->aa_ch = timeout( aarpprobe, (caddr_t)ac, hz / 5 );
553     }
554
555     if (( m = m_gethdr( MB_DONTWAIT, MT_DATA )) == NULL ) {
556         return;
557     }
558     m->m_len = sizeof( *ea );
559     m->m_pkthdr.len = sizeof( *ea );
560     MH_ALIGN( m, sizeof( *ea ));
561
562     ea = mtod( m, struct ether_aarp *);
563     bzero((caddr_t)ea, sizeof( *ea ));
564
565     ea->aarp_hrd = htons( AARPHRD_ETHER );
566     ea->aarp_pro = htons( ETHERTYPE_AT );
567     ea->aarp_hln = sizeof( ea->aarp_sha );
568     ea->aarp_pln = sizeof( ea->aarp_spu );
569     ea->aarp_op = htons( AARPOP_PROBE );
570     bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha,
571             sizeof( ea->aarp_sha ));
572
573     eh = (struct ether_header *)sa.sa_data;
574
575     if ( aa->aa_flags & AFA_PHASE2 ) {
576         bcopy((caddr_t)atmulticastaddr, (caddr_t)eh->ether_dhost,
577                 sizeof( eh->ether_dhost ));
578         eh->ether_type = htons( sizeof( struct llc ) +
579                 sizeof( struct ether_aarp ));
580         M_PREPEND( m, sizeof( struct llc ), MB_WAIT );
581         /* XXX-MBUF */
582         llc = mtod( m, struct llc *);
583         llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP;
584         llc->llc_control = LLC_UI;
585         bcopy( aarp_org_code, llc->llc_org_code, sizeof( aarp_org_code ));
586         llc->llc_ether_type = htons( ETHERTYPE_AARP );
587
588         bcopy( &AA_SAT( aa )->sat_addr.s_net, ea->aarp_spnet,
589                 sizeof( ea->aarp_spnet ));
590         bcopy( &AA_SAT( aa )->sat_addr.s_net, ea->aarp_tpnet,
591                 sizeof( ea->aarp_tpnet ));
592         ea->aarp_spnode = ea->aarp_tpnode = AA_SAT( aa )->sat_addr.s_node;
593     } else {
594         bcopy(ac->ac_if.if_broadcastaddr, eh->ether_dhost,
595               ac->ac_if.if_addrlen);
596         eh->ether_type = htons( ETHERTYPE_AARP );
597         ea->aarp_spa = ea->aarp_tpa = AA_SAT( aa )->sat_addr.s_node;
598     }
599
600 #ifdef NETATALKDEBUG
601     printf("aarp: sending probe for %u.%u\n",
602            ntohs(AA_SAT( aa )->sat_addr.s_net),
603            AA_SAT( aa )->sat_addr.s_node);
604 #endif /* NETATALKDEBUG */
605
606     sa.sa_len = sizeof( struct sockaddr );
607     sa.sa_family = AF_UNSPEC;
608     (*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */
609     aa->aa_probcnt--;
610 }
611
612 void
613 aarp_clean(void)
614 {
615     struct aarptab      *aat;
616     int                 i;
617
618     untimeout( aarptimer, 0, aarptimer_ch );
619     for ( i = 0, aat = aarptab; i < AARPTAB_SIZE; i++, aat++ ) {
620         if ( aat->aat_hold ) {
621             m_freem( aat->aat_hold );
622             aat->aat_hold = NULL;
623         }
624     }
625 }