udp_usrreq.c (b89e82dd87dec9034c8b7f1a01524dceea11ff49) | udp_usrreq.c (d10910e6cee0dca8be3d5a7fdbe404a15d9e7b52) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 3 * The Regents of the University of California. 4 * Copyright (c) 2008 Robert N. M. Watson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 399 unchanged lines hidden (view full) --- 408 continue; 409#endif 410 if (inp->inp_laddr.s_addr != INADDR_ANY && 411 inp->inp_laddr.s_addr != ip->ip_dst.s_addr) 412 continue; 413 if (inp->inp_faddr.s_addr != INADDR_ANY && 414 inp->inp_faddr.s_addr != ip->ip_src.s_addr) 415 continue; | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995 3 * The Regents of the University of California. 4 * Copyright (c) 2008 Robert N. M. Watson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 399 unchanged lines hidden (view full) --- 408 continue; 409#endif 410 if (inp->inp_laddr.s_addr != INADDR_ANY && 411 inp->inp_laddr.s_addr != ip->ip_dst.s_addr) 412 continue; 413 if (inp->inp_faddr.s_addr != INADDR_ANY && 414 inp->inp_faddr.s_addr != ip->ip_src.s_addr) 415 continue; |
416 /* 417 * XXX: Do not check source port of incoming datagram 418 * unless inp_connect() has been called to bind the 419 * fport part of the 4-tuple; the source could be 420 * trying to talk to us with an ephemeral port. 421 */ | |
422 if (inp->inp_fport != 0 && 423 inp->inp_fport != uh->uh_sport) 424 continue; 425 426 INP_RLOCK(inp); 427 428 /* 429 * Handle socket delivery policy for any-source 430 * and source-specific multicast. [RFC3678] 431 */ 432 imo = inp->inp_moptions; 433 if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && 434 imo != NULL) { | 416 if (inp->inp_fport != 0 && 417 inp->inp_fport != uh->uh_sport) 418 continue; 419 420 INP_RLOCK(inp); 421 422 /* 423 * Handle socket delivery policy for any-source 424 * and source-specific multicast. [RFC3678] 425 */ 426 imo = inp->inp_moptions; 427 if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && 428 imo != NULL) { |
435 struct sockaddr_in sin; 436 struct in_msource *ims; 437 int blocked, mode; 438 size_t idx; | 429 struct sockaddr_in group; 430 int blocked; |
439 | 431 |
440 bzero(&sin, sizeof(struct sockaddr_in)); 441 sin.sin_len = sizeof(struct sockaddr_in); 442 sin.sin_family = AF_INET; 443 sin.sin_addr = ip->ip_dst; | 432 bzero(&group, sizeof(struct sockaddr_in)); 433 group.sin_len = sizeof(struct sockaddr_in); 434 group.sin_family = AF_INET; 435 group.sin_addr = ip->ip_dst; |
444 | 436 |
445 blocked = 0; 446 idx = imo_match_group(imo, ifp, 447 (struct sockaddr *)&sin); 448 if (idx == -1) { 449 /* 450 * No group membership for this socket. 451 * Do not bump udps_noportbcast, as 452 * this will happen further down. 453 */ 454 blocked++; 455 } else { 456 /* 457 * Check for a multicast source filter 458 * entry on this socket for this group. 459 * MCAST_EXCLUDE is the default 460 * behaviour. It means default accept; 461 * entries, if present, denote sources 462 * to be excluded from delivery. 463 */ 464 ims = imo_match_source(imo, idx, 465 (struct sockaddr *)&udp_in); 466 mode = imo->imo_mfilters[idx].imf_fmode; 467 if ((ims != NULL && 468 mode == MCAST_EXCLUDE) || 469 (ims == NULL && 470 mode == MCAST_INCLUDE)) { 471#ifdef DIAGNOSTIC 472 if (bootverbose) { 473 printf("%s: blocked by" 474 " source filter\n", 475 __func__); 476 } 477#endif | 437 blocked = imo_multi_filter(imo, ifp, 438 (struct sockaddr *)&group, 439 (struct sockaddr *)&udp_in); 440 if (blocked != MCAST_PASS) { 441 if (blocked == MCAST_NOTGMEMBER) 442 V_ipstat.ips_notmember++; 443 if (blocked == MCAST_NOTSMEMBER || 444 blocked == MCAST_MUTED) |
478 V_udpstat.udps_filtermcast++; | 445 V_udpstat.udps_filtermcast++; |
479 blocked++; 480 } 481 } 482 if (blocked != 0) { | |
483 INP_RUNLOCK(inp); 484 continue; 485 } 486 } 487 if (last != NULL) { 488 struct mbuf *n; 489 490 n = m_copy(m, 0, M_COPYALL); --- 880 unchanged lines hidden --- | 446 INP_RUNLOCK(inp); 447 continue; 448 } 449 } 450 if (last != NULL) { 451 struct mbuf *n; 452 453 n = m_copy(m, 0, M_COPYALL); --- 880 unchanged lines hidden --- |