diff options
author | Ken Chen <cken@google.com> | 2024-01-23 09:06:13 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-23 09:06:13 +0000 |
commit | c4d01f5038c68014a4e447893b2eac8d7b9f578f (patch) | |
tree | 9c71abc91311cc7c9518b6006d2809689106da2c | |
parent | 9408b7e05e9dd63364300e63fd2da9cb45275d3f (diff) | |
parent | 62fff444640e3c43239b276233b6506b54cac507 (diff) | |
download | netd-c4d01f5038c68014a4e447893b2eac8d7b9f578f.tar.gz |
Merge "Delete mdns from netd" into main am: 62fff44464
Original change: https://android-review.googlesource.com/c/platform/system/netd/+/2832090
Change-Id: I0b56174144394671ccf2367b90a76981d65261ff
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | server/Android.bp | 2 | ||||
-rw-r--r-- | server/MDnsService.cpp | 128 | ||||
-rw-r--r-- | server/MDnsService.h | 44 | ||||
-rw-r--r-- | server/main.cpp | 8 | ||||
-rw-r--r-- | server/netd.rc | 1 |
5 files changed, 0 insertions, 183 deletions
diff --git a/server/Android.bp b/server/Android.bp index 2aee802f..882f0f0c 100644 --- a/server/Android.bp +++ b/server/Android.bp @@ -114,7 +114,6 @@ cc_defaults { "libselinux", "libsysutils", "libutils", - "mdns_aidl_interface-V1-cpp", "netd_event_listener_interface-V1-cpp", "oemnetd_aidl_interface-cpp", ], @@ -128,7 +127,6 @@ cc_defaults { "EventReporter.cpp", "FwmarkServer.cpp", "LocalNetwork.cpp", - "MDnsService.cpp", "NetdCommand.cpp", "NetdHwAidlService.cpp", "NetdHwService.cpp", diff --git a/server/MDnsService.cpp b/server/MDnsService.cpp deleted file mode 100644 index bb70550a..00000000 --- a/server/MDnsService.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2022, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "MDnsService" - -#include "MDnsService.h" - -#include <android-base/properties.h> -#include <binder/Status.h> -#include <binder_utils/BinderUtil.h> - -using android::net::mdns::aidl::DiscoveryInfo; -using android::net::mdns::aidl::GetAddressInfo; -using android::net::mdns::aidl::IMDnsEventListener; -using android::net::mdns::aidl::RegistrationInfo; -using android::net::mdns::aidl::ResolutionInfo; - -using std::literals::chrono_literals::operator""s; - -namespace android::net { - -#define MDNS_SERVICE_NAME "mdnsd" -#define MDNS_SERVICE_STATUS "init.svc.mdnsd" - -// TODO: DnsResolver has same macro definition but returns ScopedAStatus. Move these macros to -// BinderUtil.h to do the same permission check. -#define ENFORCE_ANY_PERMISSION(...) \ - do { \ - binder::Status status = checkAnyPermission({__VA_ARGS__}); \ - if (!status.isOk()) { \ - return status; \ - } \ - } while (0) - -#define ENFORCE_NETWORK_STACK_PERMISSIONS() \ - ENFORCE_ANY_PERMISSION(PERM_NETWORK_STACK, PERM_MAINLINE_NETWORK_STACK) - -status_t MDnsService::start() { - IPCThreadState::self()->disableBackgroundScheduling(true); - const status_t ret = BinderService<MDnsService>::publish(); - if (ret != android::OK) { - return ret; - } - return android::OK; -} - -binder::Status MDnsService::startDaemon() { - ENFORCE_NETWORK_STACK_PERMISSIONS(); - if (android::base::GetProperty(MDNS_SERVICE_STATUS, "") == "running") { - return android::binder::Status::fromServiceSpecificError(EBUSY, strerror(EBUSY)); - } - - ALOGD("Starting MDNSD"); - android::base::SetProperty("ctl.start", MDNS_SERVICE_NAME); - // To maintain the same behavior as before, the returned value is not checked. - android::base::WaitForProperty(MDNS_SERVICE_STATUS, "running", 5s); - return binder::Status::ok(); -} - -binder::Status MDnsService::stopDaemon() { - ENFORCE_NETWORK_STACK_PERMISSIONS(); - ALOGD("Stopping MDNSD"); - android::base::SetProperty("ctl.stop", MDNS_SERVICE_NAME); - android::base::WaitForProperty(MDNS_SERVICE_STATUS, "stopped", 5s); - return binder::Status::ok(); -} - -binder::Status MDnsService::registerService(const RegistrationInfo&) { - // TODO(b/298594687): switch from EX_SERVICE_SPECIFIC to DEPRECATED when tethering module - // for 2024-02 release is fully rolled out and prebuilt updated in AP1A.xxxxxx.yy build. - // Return EX_SERVICE_SPECIFIC for short-term only because callers in tethering module do not - // catch the EX_UNSUPPORTED_OPERATION. It will throw an exception and cause a fatal exception. - // The EX_UNSUPPORTED_OPERATION has been catched in tethering module since 2024-02 release. - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -binder::Status MDnsService::discover(const DiscoveryInfo&) { - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -binder::Status MDnsService::resolve(const ResolutionInfo&) { - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -binder::Status MDnsService::getServiceAddress(const GetAddressInfo&) { - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -binder::Status MDnsService::stopOperation(int32_t) { - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -binder::Status MDnsService::registerEventListener(const android::sp<IMDnsEventListener>&) { - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -binder::Status MDnsService::unregisterEventListener(const android::sp<IMDnsEventListener>&) { - // TODO(b/298594687): switch to DEPRECATED. - return binder::Status::fromExceptionCode(binder::Status::EX_SERVICE_SPECIFIC); - // DEPRECATED; -} - -} // namespace android::net diff --git a/server/MDnsService.h b/server/MDnsService.h deleted file mode 100644 index b8ead656..00000000 --- a/server/MDnsService.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2022, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include <android/net/mdns/aidl/BnMDns.h> -#include <binder/BinderService.h> - -namespace android::net { - -class MDnsService : public BinderService<MDnsService>, public android::net::mdns::aidl::BnMDns { - public: - static status_t start(); - static char const* getServiceName() { return "mdns"; } - - binder::Status startDaemon() override; - binder::Status stopDaemon() override; - binder::Status registerService( - const ::android::net::mdns::aidl::RegistrationInfo& info) override; - binder::Status discover(const ::android::net::mdns::aidl::DiscoveryInfo& info) override; - binder::Status resolve(const ::android::net::mdns::aidl::ResolutionInfo& info) override; - binder::Status getServiceAddress( - const ::android::net::mdns::aidl::GetAddressInfo& info) override; - binder::Status stopOperation(int32_t id) override; - binder::Status registerEventListener( - const android::sp<android::net::mdns::aidl::IMDnsEventListener>& listener) override; - binder::Status unregisterEventListener( - const android::sp<android::net::mdns::aidl::IMDnsEventListener>& listener) override; -}; - -} // namespace android::net diff --git a/server/main.cpp b/server/main.cpp index b0c5406d..a3a111bc 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -42,7 +42,6 @@ #include "Controllers.h" #include "FwmarkServer.h" -#include "MDnsService.h" #include "NFLogListener.h" #include "NetdConstants.h" #include "NetdHwAidlService.h" @@ -62,7 +61,6 @@ using android::net::FwmarkServer; using android::net::gCtls; using android::net::gLog; using android::net::makeNFLogListener; -using android::net::MDnsService; using android::net::NetdHwService; using android::net::NetdNativeService; using android::net::NetlinkManager; @@ -204,12 +202,6 @@ int main() { } gLog.info("Registering NetdNativeService: %" PRId64 "us", subTime.getTimeAndResetUs()); - if ((ret = MDnsService::start()) != android::OK) { - ALOGE("Unable to start MDnsService: %d", ret); - exit(1); - } - gLog.info("Registering MDnsService: %" PRId64 "us", subTime.getTimeAndResetUs()); - android::net::process::ScopedPidFile pidFile(PID_FILE_PATH); // Now that netd is ready to process commands, advertise service availability for HAL clients. diff --git a/server/netd.rc b/server/netd.rc index d8250c2d..79dbea41 100644 --- a/server/netd.rc +++ b/server/netd.rc @@ -4,7 +4,6 @@ service netd /system/bin/netd user root group root net_admin socket dnsproxyd stream 0660 root inet - socket mdns stream 0660 root system socket fwmarkd stream 0660 root inet onrestart restart zygote onrestart restart zygote_secondary |