@@ -186,7 +186,7 @@ static inline bool ipv6_drop_on_unknown_option(struct net_pkt *pkt,
186
186
case 0x40 :
187
187
break ;
188
188
case 0xc0 :
189
- if (net_ipv6_is_addr_mcast (( struct in6_addr * ) hdr -> dst )) {
189
+ if (net_ipv6_is_addr_mcast_raw ( hdr -> dst )) {
190
190
break ;
191
191
}
192
192
@@ -307,8 +307,8 @@ static struct net_route_entry *add_route(struct net_if *iface,
307
307
#endif /* CONFIG_NET_ROUTE */
308
308
309
309
static void ipv6_no_route_info (struct net_pkt * pkt ,
310
- struct in6_addr * src ,
311
- struct in6_addr * dst )
310
+ const uint8_t * src ,
311
+ const uint8_t * dst )
312
312
{
313
313
NET_DBG ("Will not route pkt %p ll src %s to dst %s between interfaces" ,
314
314
pkt , net_sprint_ipv6_addr (src ),
@@ -321,27 +321,29 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
321
321
{
322
322
struct net_route_entry * route ;
323
323
struct in6_addr * nexthop ;
324
+ struct in6_addr src_ip , dst_ip ;
324
325
bool found ;
325
326
327
+ net_ipv6_addr_copy_raw (src_ip .s6_addr , hdr -> src );
328
+ net_ipv6_addr_copy_raw (dst_ip .s6_addr , hdr -> dst );
329
+
326
330
/* Check if the packet can be routed */
327
331
if (IS_ENABLED (CONFIG_NET_ROUTING )) {
328
- found = net_route_get_info (NULL , (struct in6_addr * )hdr -> dst ,
329
- & route , & nexthop );
332
+ found = net_route_get_info (NULL , & dst_ip , & route , & nexthop );
330
333
} else {
331
- found = net_route_get_info (net_pkt_iface (pkt ),
332
- (struct in6_addr * )hdr -> dst ,
334
+ found = net_route_get_info (net_pkt_iface (pkt ), & dst_ip ,
333
335
& route , & nexthop );
334
336
}
335
337
336
338
if (found ) {
337
339
int ret ;
338
340
339
341
if (IS_ENABLED (CONFIG_NET_ROUTING ) &&
340
- (net_ipv6_is_ll_addr (( struct in6_addr * ) hdr -> src ) ||
341
- net_ipv6_is_ll_addr (( struct in6_addr * ) hdr -> dst ))) {
342
+ (net_ipv6_is_ll_addr (& src_ip ) ||
343
+ net_ipv6_is_ll_addr (& dst_ip ))) {
342
344
/* RFC 4291 ch 2.5.6 */
343
- ipv6_no_route_info (pkt , ( struct in6_addr * ) hdr -> src ,
344
- ( struct in6_addr * ) hdr -> dst );
345
+ ipv6_no_route_info (pkt , hdr -> src , hdr -> dst );
346
+
345
347
goto drop ;
346
348
}
347
349
@@ -365,8 +367,7 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
365
367
pkt , net_pkt_orig_iface (pkt ),
366
368
net_pkt_iface (pkt ));
367
369
368
- add_route (net_pkt_orig_iface (pkt ),
369
- (struct in6_addr * )hdr -> src , 128 );
370
+ add_route (net_pkt_orig_iface (pkt ), & src_ip , 128 );
370
371
}
371
372
372
373
ret = net_route_packet (pkt , nexthop );
@@ -382,7 +383,7 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
382
383
struct net_if * iface = NULL ;
383
384
int ret ;
384
385
385
- if (net_if_ipv6_addr_onlink (& iface , ( struct in6_addr * ) hdr -> dst )) {
386
+ if (net_if_ipv6_addr_onlink (& iface , & dst_ip )) {
386
387
ret = net_route_packet_if (pkt , iface );
387
388
if (ret < 0 ) {
388
389
NET_DBG ("Cannot re-route pkt %p "
@@ -394,7 +395,7 @@ static enum net_verdict ipv6_route_packet(struct net_pkt *pkt,
394
395
}
395
396
396
397
NET_DBG ("No route to %s pkt %p dropped" ,
397
- net_sprint_ipv6_addr (& hdr -> dst ), pkt );
398
+ net_sprint_ipv6_addr (& dst_ip ), pkt );
398
399
}
399
400
400
401
drop :
@@ -427,9 +428,9 @@ static enum net_verdict ipv6_forward_mcast_packet(struct net_pkt *pkt,
427
428
* 3. is from link local source
428
429
* 4. hop limit is or would become zero
429
430
*/
430
- if (net_ipv6_is_addr_mcast (( struct in6_addr * ) hdr -> src ) ||
431
- net_ipv6_is_addr_mcast_iface (( struct in6_addr * ) hdr -> dst ) ||
432
- net_ipv6_is_ll_addr (( struct in6_addr * ) hdr -> src ) || hdr -> hop_limit <= 1 ) {
431
+ if (net_ipv6_is_addr_mcast_raw ( hdr -> src ) ||
432
+ net_ipv6_is_addr_mcast_iface_raw ( hdr -> dst ) ||
433
+ net_ipv6_is_ll_addr_raw ( hdr -> src ) || hdr -> hop_limit <= 1 ) {
433
434
return NET_CONTINUE ;
434
435
}
435
436
@@ -462,11 +463,11 @@ static uint8_t extension_to_bitmap(uint8_t header, uint8_t ext_bitmap)
462
463
}
463
464
}
464
465
465
- static inline bool is_src_non_tentative_itself (struct in6_addr * src )
466
+ static inline bool is_src_non_tentative_itself (const uint8_t * src )
466
467
{
467
468
struct net_if_addr * ifaddr ;
468
469
469
- ifaddr = net_if_ipv6_addr_lookup (src , NULL );
470
+ ifaddr = net_if_ipv6_addr_lookup_raw (src , NULL );
470
471
if (ifaddr != NULL && ifaddr -> addr_state != NET_ADDR_TENTATIVE ) {
471
472
return true;
472
473
}
@@ -518,37 +519,37 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
518
519
net_sprint_ipv6_addr (& hdr -> src ),
519
520
net_sprint_ipv6_addr (& hdr -> dst ));
520
521
521
- if (net_ipv6_is_addr_unspecified (( struct in6_addr * ) hdr -> src )) {
522
+ if (net_ipv6_is_addr_unspecified_raw ( hdr -> src )) {
522
523
/* If this is a possible DAD message, let it pass. Extra checks
523
524
* are done in duplicate address detection code to verify that
524
525
* the packet is ok.
525
526
*/
526
527
if (!(IS_ENABLED (CONFIG_NET_IPV6_DAD ) &&
527
- net_ipv6_is_addr_solicited_node (( struct in6_addr * ) hdr -> dst ))) {
528
+ net_ipv6_is_addr_solicited_node_raw ( hdr -> dst ))) {
528
529
NET_DBG ("DROP: src addr is %s" , "unspecified" );
529
530
goto drop ;
530
531
}
531
532
}
532
533
533
- if (net_ipv6_is_addr_mcast (( struct in6_addr * ) hdr -> src ) ||
534
- net_ipv6_is_addr_mcast_scope (( struct in6_addr * ) hdr -> dst , 0 )) {
534
+ if (net_ipv6_is_addr_mcast_raw ( hdr -> src ) ||
535
+ net_ipv6_is_addr_mcast_scope_raw ( hdr -> dst , 0 )) {
535
536
NET_DBG ("DROP: multicast packet" );
536
537
goto drop ;
537
538
}
538
539
539
540
if (!is_loopback ) {
540
- if (net_ipv6_is_addr_loopback (( struct in6_addr * ) hdr -> dst ) ||
541
- net_ipv6_is_addr_loopback (( struct in6_addr * ) hdr -> src )) {
541
+ if (net_ipv6_is_addr_loopback_raw ( hdr -> dst ) ||
542
+ net_ipv6_is_addr_loopback_raw ( hdr -> src )) {
542
543
NET_DBG ("DROP: ::1 packet" );
543
544
goto drop ;
544
545
}
545
546
546
- if (net_ipv6_is_addr_mcast_iface (( struct in6_addr * ) hdr -> dst ) ||
547
- (net_ipv6_is_addr_mcast_group (
548
- ( struct in6_addr * ) hdr -> dst ,
549
- net_ipv6_unspecified_address ()) &&
550
- (net_ipv6_is_addr_mcast_site (( struct in6_addr * ) hdr -> dst ) ||
551
- net_ipv6_is_addr_mcast_org (( struct in6_addr * ) hdr -> dst )))) {
547
+ if (net_ipv6_is_addr_mcast_iface_raw ( hdr -> dst ) ||
548
+ (net_ipv6_is_addr_mcast_group_raw (
549
+ hdr -> dst ,
550
+ ( const uint8_t * ) net_ipv6_unspecified_address ()) &&
551
+ (net_ipv6_is_addr_mcast_site_raw ( hdr -> dst ) ||
552
+ net_ipv6_is_addr_mcast_org_raw ( hdr -> dst )))) {
552
553
NET_DBG ("DROP: invalid scope multicast packet" );
553
554
goto drop ;
554
555
}
@@ -559,7 +560,7 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
559
560
* This check is done later on if routing features are enabled.
560
561
*/
561
562
if (!IS_ENABLED (CONFIG_NET_ROUTING ) && !IS_ENABLED (CONFIG_NET_ROUTE_MCAST ) &&
562
- is_src_non_tentative_itself (( struct in6_addr * ) hdr -> src )) {
563
+ is_src_non_tentative_itself (hdr -> src )) {
563
564
NET_DBG ("DROP: src addr is %s" , "mine" );
564
565
goto drop ;
565
566
}
@@ -589,7 +590,7 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
589
590
}
590
591
591
592
if (IS_ENABLED (CONFIG_NET_ROUTE_MCAST ) &&
592
- net_ipv6_is_addr_mcast (( struct in6_addr * ) hdr -> dst ) && !net_pkt_forwarding (pkt )) {
593
+ net_ipv6_is_addr_mcast_raw ( hdr -> dst ) && !net_pkt_forwarding (pkt )) {
593
594
/* If the packet is a multicast packet and multicast routing
594
595
* is activated, we give the packet to the routing engine.
595
596
*
@@ -603,14 +604,14 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
603
604
}
604
605
}
605
606
606
- if (!net_ipv6_is_addr_mcast (( struct in6_addr * ) hdr -> dst )) {
607
- if (!net_if_ipv6_addr_lookup_by_iface (pkt_iface , ( struct in6_addr * ) hdr -> dst )) {
607
+ if (!net_ipv6_is_addr_mcast_raw ( hdr -> dst )) {
608
+ if (!net_if_ipv6_addr_lookup_by_iface_raw (pkt_iface , hdr -> dst )) {
608
609
if (ipv6_route_packet (pkt , hdr ) == NET_OK ) {
609
610
return NET_OK ;
610
611
}
611
612
612
613
NET_DBG ("DROP: no such address %s in iface %d" ,
613
- net_sprint_ipv6_addr (( struct in6_addr * ) hdr -> dst ),
614
+ net_sprint_ipv6_addr (hdr -> dst ),
614
615
net_if_get_by_iface (pkt_iface ));
615
616
goto drop ;
616
617
}
@@ -621,25 +622,23 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
621
622
* RFC 4291 ch 2.5.6
622
623
*/
623
624
if (IS_ENABLED (CONFIG_NET_ROUTING ) &&
624
- net_ipv6_is_ll_addr ((struct in6_addr * )hdr -> src ) &&
625
- !net_if_ipv6_addr_lookup_by_iface (
626
- pkt_iface , (struct in6_addr * )hdr -> dst )) {
627
- ipv6_no_route_info (pkt , (struct in6_addr * )hdr -> src ,
628
- (struct in6_addr * )hdr -> dst );
625
+ net_ipv6_is_ll_addr_raw (hdr -> src ) &&
626
+ !net_if_ipv6_addr_lookup_by_iface_raw (pkt_iface , hdr -> dst )) {
627
+ ipv6_no_route_info (pkt , hdr -> src , hdr -> dst );
629
628
NET_DBG ("DROP: cross interface boundary" );
630
629
goto drop ;
631
630
}
632
631
}
633
632
634
633
if ((IS_ENABLED (CONFIG_NET_ROUTING ) || IS_ENABLED (CONFIG_NET_ROUTE_MCAST )) &&
635
- !is_loopback && is_src_non_tentative_itself (( struct in6_addr * ) hdr -> src )) {
634
+ !is_loopback && is_src_non_tentative_itself (hdr -> src )) {
636
635
NET_DBG ("DROP: src addr is %s" , "mine" );
637
636
goto drop ;
638
637
}
639
638
640
- if (net_ipv6_is_addr_mcast (( struct in6_addr * ) hdr -> dst ) &&
641
- !(net_ipv6_is_addr_mcast_iface (( struct in6_addr * ) hdr -> dst ) ||
642
- net_ipv6_is_addr_mcast_link_all_nodes (( struct in6_addr * ) hdr -> dst ))) {
639
+ if (net_ipv6_is_addr_mcast_raw ( hdr -> dst ) &&
640
+ !(net_ipv6_is_addr_mcast_iface_raw ( hdr -> dst ) ||
641
+ net_ipv6_is_addr_mcast_link_all_nodes_raw ( hdr -> dst ))) {
643
642
/* If we receive a packet with a interface-local or
644
643
* link-local all-nodes multicast destination address we
645
644
* always have to pass it to the upper layer.
@@ -650,9 +649,7 @@ enum net_verdict net_ipv6_input(struct net_pkt *pkt, bool is_loopback)
650
649
* packet will be dropped.
651
650
* RFC4291 ch 2.7.1, ch 2.8
652
651
*/
653
- if_mcast_addr = net_if_ipv6_maddr_lookup (
654
- (struct in6_addr * )hdr -> dst , & pkt_iface );
655
-
652
+ if_mcast_addr = net_if_ipv6_maddr_lookup_raw (hdr -> dst , & pkt_iface );
656
653
if (!if_mcast_addr ||
657
654
!net_if_ipv6_maddr_is_joined (if_mcast_addr )) {
658
655
NET_DBG ("DROP: packet for unjoined multicast address" );
0 commit comments