2 * Connection oriented routing
3 * Copyright (C) 2007-2009 Michael Blizek
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * Splited packet data format:
25 * announce proto version [4]
26 * is 0, may be increased if format changes
28 * starts with 0, increments every time the data field changes
30 * total data size of all merged packets
32 * used to determine the order when merging the split packet
35 * commulative checksum [8] (not yet)
36 * chunk 1 contains the checksum of the data in chunk 1
37 * chunk 2 contains the checksum of the data in chunk 1+2
40 * Data format of the announce packet "data" field:
41 * min_announce_proto_version [4]
42 * max_announce_proto_version [4]
43 * min_cor_proto_version [4]
44 * max_cor_proto_version [4]
45 * versions which are understood
49 * commanddata [commandlength]
54 #define NEIGHCMD_ADDADDR 1
59 * addrtype [addrtypelen]
66 * "I hear you" data format:
71 DEFINE_MUTEX(neighbor_operation_lock
);
73 char *addrtype
= "id";
79 struct kmem_cache
*nb_slab
;
81 LIST_HEAD(announce_out_list
);
83 struct notifier_block netdev_notify
;
86 #define ADDRTYPE_UNKNOWN 0
89 static int get_addrtype(__u32 addrtypelen
, char *addrtype
)
91 if (addrtypelen
== 2 &&
92 (addrtype
[0] == 'i' || addrtype
[0] == 'I') &&
93 (addrtype
[1] == 'd' || addrtype
[1] == 'D'))
96 return ADDRTYPE_UNKNOWN
;
99 static void neighbor_free(struct ref_counter
*ref
)
101 struct neighbor
*nb
= container_of(ref
, struct neighbor
, refs
);
102 BUG_ON(nb
->nb_list
.next
!= 0 || nb
->nb_list
.prev
!= 0);
109 kmem_cache_free(nb_slab
, nb
);
112 static struct ref_counter_def neighbor_ref
= {
113 .free
= neighbor_free
116 static struct neighbor
*alloc_neighbor(gfp_t allocflags
)
118 struct neighbor
*nb
= kmem_cache_alloc(nb_slab
, allocflags
);
125 memset(nb
, 0, sizeof(struct neighbor
));
127 ref_counter_init(&(nb
->refs
), &neighbor_ref
);
128 mutex_init(&(nb
->cmsg_lock
));
129 INIT_LIST_HEAD(&(nb
->control_msgs_out
));
130 nb
->last_ping_time
= jiffies
;
131 atomic_set(&(nb
->ooo_packets
), 0);
132 get_random_bytes((char *) &seqno
, sizeof(seqno
));
133 atomic_set(&(nb
->kpacket_seqno
), seqno
);
135 mutex_init(&(nb
->conn_list_lock
));
136 INIT_LIST_HEAD(&(nb
->rcv_conn_list
));
137 INIT_LIST_HEAD(&(nb
->snd_conn_list
));
138 spin_lock_init(&(nb
->retrans_lock
));
139 spin_lock_init(&(nb
->retrans_lock
));
140 skb_queue_head_init(&(nb
->retrans_list
));
145 struct neighbor
*get_neigh_by_mac(struct sk_buff
*skb
)
147 struct list_head
*currlh
;
148 struct neighbor
*ret
= 0;
151 char source_hw
[MAX_ADDR_LEN
];
152 memset(source_hw
, 0, MAX_ADDR_LEN
);
153 if (skb
->dev
->header_ops
!= 0 &&
154 skb
->dev
->header_ops
->parse
!= 0)
155 skb
->dev
->header_ops
->parse(skb
, source_hw
);
157 mutex_lock(&(neighbor_operation_lock
));
159 currlh
= nb_list
.next
;
161 while (currlh
!= &nb_list
) {
162 struct neighbor
*curr
= container_of(currlh
, struct neighbor
,
165 if (memcmp(curr
->mac
, source_hw
, MAX_ADDR_LEN
) == 0) {
167 ref_counter_incr(&(ret
->refs
));
172 currlh
= currlh
->next
;
176 mutex_unlock(&(neighbor_operation_lock
));
181 struct neighbor
*find_neigh(__u16 addrtypelen
, __u8
*addrtype
,
182 __u16 addrlen
, __u8
*addr
)
184 struct list_head
*currlh
;
185 struct neighbor
*ret
= 0;
187 if (get_addrtype(addrtypelen
, addrtype
) != ADDRTYPE_ID
)
190 mutex_lock(&(neighbor_operation_lock
));
192 currlh
= nb_list
.next
;
194 while (currlh
!= &nb_list
) {
195 struct neighbor
*curr
= container_of(currlh
, struct neighbor
,
198 if (curr
->addrlen
== addrlen
&& memcmp(curr
->addr
, addr
,
201 ref_counter_incr(&(ret
->refs
));
206 currlh
= currlh
->next
;
210 mutex_unlock(&(neighbor_operation_lock
));
215 __u32
generate_neigh_list(char *buf
, __u32 buflen
, __u32 limit
, __u32 offset
)
217 struct list_head
*currlh
;
219 char *p_totalneighs
= buf
;
220 char *p_response_rows
= buf
+ 4;
225 __u32 buf_offset
= 8;
230 mutex_lock(&(neighbor_operation_lock
));
232 currlh
= nb_list
.next
;
234 while (currlh
!= &nb_list
) {
235 struct neighbor
*curr
= container_of(currlh
, struct neighbor
,
241 if (unlikely(buflen
- buf_offset
- 6 - 2 - curr
->addrlen
< 0))
244 put_u16(buf
+ buf_offset
, 1, 1);/* numaddr */
246 put_u16(buf
+ buf_offset
, 2, 1);/* addrtypelen */
248 put_u16(buf
+ buf_offset
, curr
->addrlen
, 1);/* addren */
250 buf
[buf_offset
] = 'i'; /* addrtype */
252 buf
[buf_offset
] = 'd';
254 memcpy(buf
+ buf_offset
, curr
->addr
, curr
->addrlen
); /* addr */
255 buf_offset
+= curr
->addrlen
;
257 BUG_ON(buf_offset
> buflen
);
263 currlh
= currlh
->next
;
266 mutex_unlock(&(neighbor_operation_lock
));
268 put_u32(p_totalneighs
, total
, 1);
269 put_u32(p_response_rows
, cnt
, 1);
274 static struct cookie
*find_cookie(struct neighbor
*nb
, __u32 cookie
)
278 for(i
=0;i
<PING_COOKIES_PER_NEIGH
;i
++) {
279 if (nb
->cookies
[i
].cookie
== cookie
)
280 return &(nb
->cookies
[i
]);
285 void ping_resp(struct neighbor
*nb
, __u32 cookie
, __u32 respdelay
)
289 __u32
add_ping_req(struct neighbor
*nb
)
296 * Check additional to the checks and timings already done in kpacket_gen.c
297 * This is primarily to make sure that we do not invalidate other ping cookies
298 * which might still receive responses. It does this by requiring a certain
299 * mimimum delay between pings, depending on how many pings are already in
302 int time_to_send_ping(struct neighbor
*nb
)
304 if (nb
->ping_intransit
>= PING_COOKIES_NOTHROTTLE
) {
305 __u32 mindelay
= (nb
->latency
/1000) <<
306 (nb
->ping_intransit
+ 1 - PING_COOKIES_NOTHROTTLE
);
307 if (mindelay
> PING_THROTTLE_LIMIT_MS
)
308 mindelay
= PING_THROTTLE_LIMIT_MS
;
310 if (jiffies_to_msecs(jiffies
- nb
->last_ping_time
) < mindelay
)
317 static void add_neighbor(struct neighbor
*nb
)
319 struct list_head
*currlh
= nb_list
.next
;
321 BUG_ON((nb
->addr
== 0) != (nb
->addrlen
== 0));
323 while (currlh
!= &nb_list
) {
324 struct neighbor
*curr
= container_of(currlh
, struct neighbor
,
327 if (curr
->addrlen
== nb
->addrlen
&& memcmp(curr
->addr
, nb
->addr
,
329 goto already_present
;
331 currlh
= currlh
->next
;
334 list_add_tail(&(nb
->nb_list
), &nb_list
);
335 schedule_controlmsg_timerfunc(nb
);
336 setup_timer(&(nb
->retrans_timer
), retransmit_timerfunc
,
341 kmem_cache_free(nb_slab
, nb
);
345 static __u32
pull_u32(struct sk_buff
*skb
, int convbo
)
347 char *ptr
= cor_pull_skb(skb
, 4);
353 ((char *)&ret
)[0] = ptr
[0];
354 ((char *)&ret
)[1] = ptr
[1];
355 ((char *)&ret
)[2] = ptr
[2];
356 ((char *)&ret
)[3] = ptr
[3];
359 return be32_to_cpu(ret
);
363 static int apply_announce_addaddr(struct neighbor
*nb
, __u32 cmd
, __u32 len
,
371 BUG_ON((nb
->addr
== 0) != (nb
->addrlen
== 0));
379 addrtypelen
= be16_to_cpu(*((__u16
*) cmddata
));
386 addrlen
= be16_to_cpu(*((__u16
*) cmddata
));
391 cmddata
+= addrtypelen
;
401 if (get_addrtype(addrtypelen
, addrtype
) != ADDRTYPE_ID
)
404 nb
->addr
= kmalloc(addrlen
, GFP_KERNEL
);
408 memcpy(nb
->addr
, addr
, addrlen
);
409 nb
->addrlen
= addrlen
;
414 static void apply_announce_cmd(struct neighbor
*nb
, __u32 cmd
, __u32 len
,
417 if (cmd
== NEIGHCMD_ADDADDR
) {
418 apply_announce_addaddr(nb
, cmd
, len
, cmddata
);
420 /* ignore unknown cmds */
424 static void apply_announce_cmds(char *msg
, __u32 len
, struct net_device
*dev
,
427 struct neighbor
*nb
= alloc_neighbor(GFP_KERNEL
);
436 cmd
= be32_to_cpu(*((__u32
*) msg
));
439 cmdlen
= be32_to_cpu(*((__u32
*) msg
));
443 BUG_ON(cmdlen
> len
);
445 apply_announce_cmd(nb
, cmd
, cmdlen
, msg
);
453 memcpy(nb
->mac
, source_hw
, MAX_ADDR_LEN
);
461 static int check_announce_cmds(char *msg
, __u32 len
)
467 cmd
= be32_to_cpu(*((__u32
*) msg
));
470 cmdlen
= be32_to_cpu(*((__u32
*) msg
));
474 /* malformated packet */
488 static void parse_announce(char *msg
, __u32 len
, struct net_device
*dev
,
491 __u32 min_announce_version
;
492 __u32 max_announce_version
;
493 __u32 min_cor_version
;
494 __u32 max_cor_version
;
499 min_announce_version
= be32_to_cpu(*((__u32
*) msg
));
502 max_announce_version
= be32_to_cpu(*((__u32
*) msg
));
505 min_cor_version
= be32_to_cpu(*((__u32
*) msg
));
508 max_cor_version
= be32_to_cpu(*((__u32
*) msg
));
512 if (min_announce_version
!= 0)
514 if (min_cor_version
!= 0)
516 if (check_announce_cmds(msg
, len
)) {
519 apply_announce_cmds(msg
, len
, dev
, source_hw
);
523 /* lh has to be first */
525 struct sk_buff_head skbs
; /* sorted by offset */
526 struct net_device
*dev
;
527 char source_hw
[MAX_ADDR_LEN
];
528 __u32 announce_proto_version
;
529 __u32 packet_version
;
532 __u64 last_received_packet
;
535 LIST_HEAD(announce_list
);
537 struct kmem_cache
*announce_in_slab
;
539 static void merge_announce(struct announce_in
*ann
)
541 char *msg
= kmalloc(ann
->total_size
, GFP_KERNEL
);
545 /* try again when next packet arrives */
549 while (copy
!= ann
->total_size
) {
553 if (skb_queue_empty(&(ann
->skbs
))) {
554 printk(KERN_ERR
"net/cor/neighbor.c: sk_head ran "
555 "empty while merging packets\n");
559 skb
= skb_dequeue(&(ann
->skbs
));
563 if (currcpy
+ copy
> ann
->total_size
)
566 #warning todo overlapping skbs
567 memcpy(msg
+ copy
, skb
->data
, currcpy
);
572 parse_announce(msg
, ann
->total_size
, ann
->dev
, ann
->source_hw
);
579 list_del(&(ann
->lh
));
580 kmem_cache_free(announce_in_slab
, ann
);
583 static int _rcv_announce(struct sk_buff
*skb
, struct announce_in
*ann
)
585 struct skb_procstate
*ps
= skb_pstate(skb
);
587 __u32 offset
= ps
->funcstate
.announce
.offset
;
588 __u32 len
= skb
->len
;
590 __u32 curroffset
= 0;
591 __u32 prevoffset
= 0;
594 struct sk_buff
*curr
= ann
->skbs
.next
;
596 if (len
+ offset
> ann
->total_size
) {
603 * Try to find the right place to insert in the sorted list. This
604 * means to process the list until we find a skb which has a greater
605 * offset, so we can insert before it to keep the sort order. However,
606 * this is complicated by the fact that the new skb must not be inserted
607 * between 2 skbs if there is no data missing in between. So the loop
608 * runs has to keep running until there is either a gap to insert or
609 * we see that this data has already been received.
611 while ((void *) curr
!= (void *) &(ann
->skbs
)) {
612 struct skb_procstate
*currps
= skb_pstate(skb
);
614 curroffset
= currps
->funcstate
.announce
.offset
;
616 if (curroffset
> offset
&& (prevoffset
+ prevlen
) < curroffset
)
619 prevoffset
= curroffset
;
623 if ((offset
+len
) <= (prevoffset
+prevlen
)) {
624 /* we already have this data */
631 * Calculate how much data was really received, by substracting
632 * the bytes we already have.
634 if (unlikely(prevoffset
+ prevlen
> offset
)) {
635 len
-= (prevoffset
+ prevlen
) - offset
;
636 offset
= prevoffset
+ prevlen
;
639 if (unlikely((void *) curr
!= (void *) &(ann
->skbs
) &&
640 (offset
+ len
) > curroffset
))
641 len
= curroffset
- offset
;
643 ann
->received_size
+= len
;
644 BUG_ON(ann
->received_size
> ann
->total_size
);
645 __skb_queue_before(&(ann
->skbs
), curr
, skb
);
646 ann
->last_received_packet
= get_jiffies_64();
648 if (ann
->received_size
== ann
->total_size
)
650 else if (ann
->skbs
.qlen
>= 16)
656 void rcv_announce(struct sk_buff
*skb
)
658 struct skb_procstate
*ps
= skb_pstate(skb
);
659 struct announce_in
*curr
= 0;
660 struct announce_in
*leastactive
= 0;
663 __u32 announce_proto_version
= pull_u32(skb
, 1);
664 __u32 packet_version
= pull_u32(skb
, 1);
665 __u32 total_size
= pull_u32(skb
, 1);
667 char source_hw
[MAX_ADDR_LEN
];
668 memset(source_hw
, 0, MAX_ADDR_LEN
);
669 if (skb
->dev
->header_ops
!= 0 &&
670 skb
->dev
->header_ops
->parse
!= 0)
671 skb
->dev
->header_ops
->parse(skb
, source_hw
);
673 ps
->funcstate
.announce
.offset
= pull_u32(skb
, 1);
675 if (total_size
> 8192)
678 mutex_lock(&(neighbor_operation_lock
));
680 if (announce_proto_version
!= 0)
683 curr
= (struct announce_in
*) announce_list
.next
;
685 while (((struct list_head
*) curr
) != &(announce_list
)) {
687 if (curr
->dev
== skb
->dev
&&
688 memcmp(curr
->source_hw
, source_hw
, MAX_ADDR_LEN
) == 0 &&
689 curr
->announce_proto_version
== announce_proto_version
&&
690 curr
->packet_version
== packet_version
&&
691 curr
->total_size
== total_size
)
694 if (leastactive
== 0 || curr
->last_received_packet
<
695 leastactive
->last_received_packet
)
698 curr
= (struct announce_in
*) curr
->lh
.next
;
701 if (list_size
>= 128) {
702 BUG_ON(leastactive
== 0);
705 curr
->last_received_packet
= get_jiffies_64();
707 while (!skb_queue_empty(&(curr
->skbs
))) {
708 struct sk_buff
*skb2
= skb_dequeue(&(curr
->skbs
));
714 curr
= kmem_cache_alloc(announce_in_slab
,
719 skb_queue_head_init(&(curr
->skbs
));
720 list_add_tail((struct list_head
*) curr
, &announce_list
);
723 curr
->packet_version
= packet_version
;
724 curr
->total_size
= total_size
;
725 curr
->received_size
= 0;
726 curr
->announce_proto_version
= announce_proto_version
;
727 curr
->dev
= skb
->dev
;
729 memcpy(curr
->source_hw
, source_hw
, MAX_ADDR_LEN
);
732 if (_rcv_announce(skb
, curr
)) {
733 list_del((struct list_head
*) curr
);
735 kmem_cache_free(announce_in_slab
, curr
);
743 mutex_unlock(&(neighbor_operation_lock
));
747 struct ref_counter refs
;
749 __u32 packet_version
;
751 __u32 announce_msg_len
;
754 struct announce
*last_announce
;
756 struct announce_data
{
757 struct delayed_work announce_work
;
759 struct net_device
*dev
;
761 struct announce
*ann
;
765 __u32 curr_announce_msg_offset
;
766 __u64 scheduled_announce_timer
;
769 static void _splitsend_announce(struct announce_data
*ann
)
772 __u32 packet_size
= 256;
773 __u32 remainingdata
= ann
->ann
->announce_msg_len
-
774 ann
->curr_announce_msg_offset
;
775 __u32 headroom
= LL_ALLOCATED_SPACE(ann
->dev
);
776 __u32 overhead
= 17 + headroom
;
780 if (remainingdata
< packet_size
)
781 packet_size
= remainingdata
;
783 skb
= alloc_skb(packet_size
+ overhead
, GFP_KERNEL
);
784 if (unlikely(0 == skb
))
787 skb
->protocol
= htons(ETH_P_COR
);
789 skb_reserve(skb
, headroom
);
791 if(unlikely(dev_hard_header(skb
, ann
->dev
, ETH_P_COR
,
792 ann
->dev
->broadcast
, ann
->dev
->dev_addr
, skb
->len
) < 0))
795 skb_reset_network_header(skb
);
797 header
= skb_put(skb
, 17);
798 if (unlikely(header
== 0))
801 header
[0] = PACKET_TYPE_ANNOUNCE
;
803 put_u32(header
+ 1, 0, 1); /* announce proto version */
804 put_u32(header
+ 5, ann
->ann
->packet_version
, 1); /* packet version */
805 put_u32(header
+ 9, ann
->ann
->announce_msg_len
, 1); /* total size */
806 put_u32(header
+ 13, ann
->curr_announce_msg_offset
, 1); /* offset */
808 ptr
= skb_put(skb
, packet_size
);
809 if (unlikely(ptr
== 0))
812 memcpy(ptr
, ann
->ann
->announce_msg
+ ann
->curr_announce_msg_offset
, packet_size
);
815 ann
->curr_announce_msg_offset
+= packet_size
;
817 if (ann
->curr_announce_msg_offset
== ann
->ann
->announce_msg_len
)
818 ann
->curr_announce_msg_offset
= 0;
827 static void splitsend_announce(struct work_struct
*work
)
829 struct announce_data
*ann
= container_of(to_delayed_work(work
),
830 struct announce_data
, announce_work
);
833 mutex_lock(&(neighbor_operation_lock
));
840 if (ann
->ann
== 0 && last_announce
== 0)
843 if (ann
->curr_announce_msg_offset
== 0 && ann
->ann
!= last_announce
) {
845 ref_counter_decr(&(ann
->ann
->refs
));
846 ann
->ann
= last_announce
;
847 ref_counter_incr(&(ann
->ann
->refs
));
850 _splitsend_announce(ann
);
852 mutex_unlock(&(neighbor_operation_lock
));
855 int target_delay_ms
= 500;
856 int target_delay_jiffies
= msecs_to_jiffies(target_delay_ms
);
857 __u64 jiffies
= get_jiffies_64();
860 ann
->scheduled_announce_timer
+= target_delay_jiffies
;
862 delay
= ann
->scheduled_announce_timer
- jiffies
;
866 INIT_DELAYED_WORK(&(ann
->announce_work
), splitsend_announce
);
867 schedule_delayed_work(&(ann
->announce_work
), delay
);
871 static void announce_free(struct ref_counter
*ref
)
873 struct announce
*ann
= container_of(ref
, struct announce
, refs
);
874 kfree(&(ann
->announce_msg
));
878 static struct ref_counter_def announce_ref
= {
879 .free
= announce_free
882 static struct announce_data
*get_announce_by_netdev(struct net_device
*dev
)
884 struct list_head
*lh
= announce_out_list
.next
;
886 while (lh
!= &announce_out_list
) {
887 struct announce_data
*curr
= (struct announce_data
*)(
889 offsetof(struct announce_data
, lh
));
891 if (curr
->dev
== dev
)
898 static void announce_sent_adddev(struct net_device
*dev
)
900 struct announce_data
*ann
;
902 ann
= kmalloc(sizeof(struct announce_data
), GFP_KERNEL
);
905 printk(KERN_ERR
"cor cannot allocate memory for sending "
910 memset(ann
, 0, sizeof(struct announce_data
));
915 mutex_lock(&(neighbor_operation_lock
));
916 list_add_tail(&(ann
->lh
), &announce_out_list
);
917 mutex_unlock(&(neighbor_operation_lock
));
919 ann
->scheduled_announce_timer
= get_jiffies_64();
920 INIT_DELAYED_WORK(&(ann
->announce_work
), splitsend_announce
);
921 schedule_delayed_work(&(ann
->announce_work
), 1);
924 static void announce_sent_rmdev(struct net_device
*dev
)
926 struct announce_data
*ann
;
928 mutex_lock(&(neighbor_operation_lock
));
930 ann
= get_announce_by_netdev(dev
);
939 mutex_unlock(&(neighbor_operation_lock
));
942 int netdev_notify_func(struct notifier_block
*not, unsigned long event
,
945 struct net_device
*dev
= (struct net_device
*) ptr
;
949 announce_sent_adddev(dev
);
952 announce_sent_rmdev(dev
);
956 case NETDEV_REGISTER
:
957 case NETDEV_UNREGISTER
:
958 case NETDEV_CHANGEMTU
:
959 case NETDEV_CHANGEADDR
:
960 case NETDEV_GOING_DOWN
:
961 case NETDEV_CHANGENAME
:
962 case NETDEV_FEAT_CHANGE
:
963 case NETDEV_BONDING_FAILOVER
:
972 static int set_announce(char *msg
, __u32 len
)
974 struct announce
*ann
= kmalloc(sizeof(struct announce
), GFP_KERNEL
);
981 memset(ann
, 0, sizeof(struct announce
));
983 ann
->announce_msg
= msg
;
984 ann
->announce_msg_len
= len
;
986 ref_counter_init(&(ann
->refs
), &announce_ref
);
988 mutex_lock(&(neighbor_operation_lock
));
990 if (last_announce
!= 0) {
991 ann
->packet_version
= last_announce
->packet_version
+ 1;
992 ref_counter_decr(&(last_announce
->refs
));
997 mutex_unlock(&(neighbor_operation_lock
));
1002 static int generate_announce(void)
1004 __u32 addrtypelen
= strlen(addrtype
);
1007 __u32 cmd_hdr_len
= 8;
1008 __u32 cmd_len
= 2 + 2 + addrtypelen
+ addrlen
;
1010 __u32 len
= hdr_len
+ cmd_hdr_len
+ cmd_len
;
1013 char *msg
= kmalloc(len
, GFP_KERNEL
);
1017 put_u32(msg
+ offset
, 0, 1); /* min_announce_proto_version */
1019 put_u32(msg
+ offset
, 0, 1); /* max_announce_proto_version */
1021 put_u32(msg
+ offset
, 0, 1); /* min_cor_proto_version */
1023 put_u32(msg
+ offset
, 0, 1); /* max_cor_proto_version */
1027 put_u32(msg
+ offset
, NEIGHCMD_ADDADDR
, 1); /* command */
1029 put_u32(msg
+ offset
, cmd_len
, 1); /* command length */
1032 /* addrtypelen, addrlen */
1033 put_u16(msg
+ offset
, addrtypelen
, 1);
1035 put_u16(msg
+ offset
, addrlen
, 1);
1038 /* addrtype, addr */
1039 memcpy(msg
+ offset
, addrtype
, addrtypelen
);
1040 offset
+= addrtypelen
;
1041 memcpy(msg
+ offset
, addr
, addrlen
);
1044 BUG_ON(offset
!= len
);
1046 return set_announce(msg
, len
);
1049 int __init
cor_neighbor_init(void)
1053 addr
= kmalloc(addrlen
, GFP_KERNEL
);
1057 get_random_bytes(addr
, addrlen
);
1059 nb_slab
= kmem_cache_create("cor_neighbor", sizeof(struct neighbor
), 8,
1061 announce_in_slab
= kmem_cache_create("cor_announce_in",
1062 sizeof(struct announce_in
), 8, 0, 0);
1064 if (generate_announce())
1067 memset(&netdev_notify
, 0, sizeof(netdev_notify
));
1068 netdev_notify
.notifier_call
= netdev_notify_func
;
1069 register_netdevice_notifier(&netdev_notify
);
1080 MODULE_LICENSE("GPL");