Re: Bluetooth with Linux network namespace

From: Hayden James
Date: Thu Dec 28 2023 - 21:52:55 EST


(Resending because I had HTML turned on)

On Thu, Dec 28, 2023 at 8:44 PM Hayden James <hayden.james@xxxxxxxxx> wrote:
>
> Any reason why this patch can't be merged so that Bluetooth sockets can be created in network namespaces?
>
> https://lore.kernel.org/lkml/20170814071640.289327-1-fupan.li@xxxxxxxxxxxxx/
>
> As of the latest dev kernel on 12/28/2023 (6.7-rc7), this still doesn't work.
>
> Socket with AF_BLUETOOTH:
> int main() {
> auto fd = socket(AF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, BTPROTO_HCI);
> if (fd == -1) {
> std::cerr << strerror(errno) << std::endl;
> return EXIT_FAILURE;
> }
> else {
> std::cout << "Successfully opened bluetooth socket" << std::endl;
> close(fd);
> return EXIT_SUCCESS;
> }
> }
>
> Failure with network namespace:
> hjames@ubuntu:~$ docker run --rm -it --net=bridge hjames/bluetest bluetest
> Address family not supported by protocol
>
> Success with network without network namespace:
> hjames@ubuntu:~$ docker run --rm -it --net=host hjames/bluetest bluetest
> Successfully opened Bluetooth socket