6633549: (dc) Include-mode filtering of IPv6 sources does not block datagrams on Linux
Reviewed-by: chegar
This commit is contained in:
parent
3db0a0443c
commit
dad0499822
@ -34,6 +34,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nio_util.h"
|
||||
#include <limits.h>
|
||||
|
@ -39,83 +39,6 @@
|
||||
#include "nio_util.h"
|
||||
#include "nio.h"
|
||||
|
||||
/**
|
||||
* Definitions for source-specific multicast to allow for building
|
||||
* with older header files.
|
||||
*/
|
||||
|
||||
#ifdef __solaris__
|
||||
|
||||
#ifndef IP_BLOCK_SOURCE
|
||||
|
||||
#define IP_BLOCK_SOURCE 0x15
|
||||
#define IP_UNBLOCK_SOURCE 0x16
|
||||
#define IP_ADD_SOURCE_MEMBERSHIP 0x17
|
||||
#define IP_DROP_SOURCE_MEMBERSHIP 0x18
|
||||
|
||||
#define MCAST_BLOCK_SOURCE 0x2b
|
||||
#define MCAST_UNBLOCK_SOURCE 0x2c
|
||||
#define MCAST_JOIN_SOURCE_GROUP 0x2d
|
||||
#define MCAST_LEAVE_SOURCE_GROUP 0x2e
|
||||
|
||||
#endif /* IP_BLOCK_SOURCE */
|
||||
|
||||
struct my_ip_mreq_source {
|
||||
struct in_addr imr_multiaddr;
|
||||
struct in_addr imr_sourceaddr;
|
||||
struct in_addr imr_interface;
|
||||
};
|
||||
|
||||
/*
|
||||
* Use #pragma pack() construct to force 32-bit alignment on amd64.
|
||||
*/
|
||||
#if defined(amd64)
|
||||
#pragma pack(4)
|
||||
#endif
|
||||
|
||||
struct my_group_source_req {
|
||||
uint32_t gsr_interface; /* interface index */
|
||||
struct sockaddr_storage gsr_group; /* group address */
|
||||
struct sockaddr_storage gsr_source; /* source address */
|
||||
};
|
||||
|
||||
#if defined(amd64)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif /* __solaris__ */
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#ifndef IP_BLOCK_SOURCE
|
||||
|
||||
#define IP_BLOCK_SOURCE 38
|
||||
#define IP_UNBLOCK_SOURCE 37
|
||||
#define IP_ADD_SOURCE_MEMBERSHIP 39
|
||||
#define IP_DROP_SOURCE_MEMBERSHIP 40
|
||||
|
||||
#define MCAST_BLOCK_SOURCE 43
|
||||
#define MCAST_UNBLOCK_SOURCE 44
|
||||
#define MCAST_JOIN_SOURCE_GROUP 42
|
||||
#define MCAST_LEAVE_SOURCE_GROUP 45
|
||||
|
||||
#endif /* IP_BLOCK_SOURCE */
|
||||
|
||||
struct my_ip_mreq_source {
|
||||
struct in_addr imr_multiaddr;
|
||||
struct in_addr imr_interface;
|
||||
struct in_addr imr_sourceaddr;
|
||||
};
|
||||
|
||||
struct my_group_source_req {
|
||||
uint32_t gsr_interface; /* interface index */
|
||||
struct sockaddr_storage gsr_group; /* group address */
|
||||
struct sockaddr_storage gsr_source; /* source address */
|
||||
};
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef _ALLBSD_SOURCE
|
||||
|
||||
#ifndef IP_BLOCK_SOURCE
|
||||
@ -155,7 +78,12 @@ struct my_group_source_req {
|
||||
struct sockaddr_storage gsr_source; /* source address */
|
||||
};
|
||||
|
||||
#endif /* _ALLBSD_SOURCE */
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
|
||||
#define my_ip_mreq_source ip_mreq_source
|
||||
#define my_group_source_req group_source_req
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define COPY_INET6_ADDRESS(env, source, target) \
|
||||
@ -576,8 +504,8 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec
|
||||
optval = (void*)&mreq6;
|
||||
optlen = sizeof(mreq6);
|
||||
} else {
|
||||
#if defined (__linux__) || defined(MACOSX)
|
||||
/* Include-mode filtering broken on Mac OS & Linux at least to 2.6.24 */
|
||||
#ifdef MACOSX
|
||||
/* no IPv6 include-mode filtering for now */
|
||||
return IOS_UNAVAILABLE;
|
||||
#else
|
||||
initGroupSourceReq(env, group, index, source, &req);
|
||||
|
@ -22,10 +22,11 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4527345 7026376
|
||||
* @bug 4527345 7026376 6633549
|
||||
* @summary Unit test for DatagramChannel's multicast support
|
||||
* @build MulticastSendReceiveTests NetworkConfiguration
|
||||
* @run main MulticastSendReceiveTests
|
||||
* @run main/othervm -Djava.net.preferIPv4Stack=true MulticastSendReceiveTests
|
||||
*/
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@ -186,6 +187,10 @@ public class MulticastSendReceiveTests {
|
||||
id = sendDatagram(source, nif, group, port);
|
||||
receiveDatagram(dc, source, id);
|
||||
} catch (UnsupportedOperationException x) {
|
||||
String os = System.getProperty("os.name");
|
||||
// Exclude-mode filtering supported on these platforms so UOE should never be thrown
|
||||
if (os.equals("SunOS") || os.equals("Linux"))
|
||||
throw x;
|
||||
System.out.println("Exclude-mode filtering not supported!");
|
||||
}
|
||||
|
||||
@ -212,6 +217,10 @@ public class MulticastSendReceiveTests {
|
||||
id = sendDatagram(source, nif, group, port);
|
||||
receiveDatagram(dc, source, id);
|
||||
} catch (UnsupportedOperationException x) {
|
||||
String os = System.getProperty("os.name");
|
||||
// Include-mode filtering supported on these platforms so UOE should never be thrown
|
||||
if (os.equals("SunOS") || os.equals("Linux"))
|
||||
throw x;
|
||||
System.out.println("Include-mode filtering not supported!");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user