3 * Copyright 2018 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <grpc/support/port_platform.h>
21 #include "src/core/lib/iomgr/port.h"
23 #include <grpc/impl/codegen/log.h>
24 #include "src/core/lib/iomgr/internal_errqueue.h"
26 #ifdef GRPC_POSIX_SOCKET_TCP
31 #include <sys/utsname.h>
34 static bool errqueue_supported = false;
36 bool kernel_supports_errqueue() { return errqueue_supported; }
38 void grpc_errqueue_init() {
39 /* Both-compile time and run-time linux kernel versions should be at least 4.0.0
41 #ifdef GRPC_LINUX_ERRQUEUE
42 struct utsname buffer;
43 if (uname(&buffer) != 0) {
44 gpr_log(GPR_ERROR, "uname: %s", strerror(errno));
47 char* release = buffer.release;
48 if (release == nullptr) {
52 if (strtol(release, nullptr, 10) >= 4) {
53 errqueue_supported = true;
55 gpr_log(GPR_DEBUG, "ERRQUEUE support not enabled");
57 #endif /* GRPC_LINUX_ERRQUEUE */
59 } /* namespace grpc_core */
64 void grpc_errqueue_init() {}
65 } /* namespace grpc_core */
67 #endif /* GRPC_POSIX_SOCKET_TCP */