Skip to content

Adjust code for AsteroidOSSync/pull/216#1

Open
I-asked wants to merge 6 commits intoAsteroidOS:mainfrom
I-asked:libslirp
Open

Adjust code for AsteroidOSSync/pull/216#1
I-asked wants to merge 6 commits intoAsteroidOS:mainfrom
I-asked:libslirp

Conversation

@I-asked
Copy link
Copy Markdown

@I-asked I-asked commented May 2, 2024

This PR is merely a dependency of the following PR: AsteroidOS/AsteroidOSSync#216

I-asked added 6 commits April 30, 2024 09:12
- Use Connman for managing the TAP interface
- Rely on kernel packet fragmentation instead of a custom header
- Respect the negotiated MTU when choosing the TAP MTU
Comment thread src/ble.cpp
if (mCurrentMtu != mtu) {
mCurrentMtu = mtu;
emit mtuChanged(mtu);
emit mtuChanged(mtu - 3);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the origin of this constant ? And extract it into a named macro maybe ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And squash thsi into the code that introduced it :)

Comment thread asteroid-tap2ble.service Outdated
User=ceres
Group=ceres
AmbientCapabilities=CAP_NET_ADMIN
NoNewPrivileges=true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's awkward to introduce those lines and delete them as part of the same PR. Could you squash those changes into one commit ?

Comment thread README.md
@@ -1,4 +1,16 @@
# asteroid-tap2ble
asteroid-tap2ble
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention across our projects seems to be #

I don't care all that much but let's just stay consistent with what we already have https://github.com/AsteroidOS/asteroid-calculator/blob/master/README.md?plain=1#L1

Comment thread README.md
This daemon creates a TAP interface and exposes a BLE service with a RX and a
TX characteristic. These map to read/write operations on that TAP interface.

D-Bus forwarding
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a more helpful commit title would be "Document D-Bus forwarding"

Comment thread src/ble-dbus.h
#define TX_UUID "00001002-0000-0000-0000-00A57E401D05"
#define SERVICE_UUID "0000A071-0000-0000-0000-00A57E401D05"
#define RX_UUID "0000A001-0000-0000-0000-00A57E401D05"
#define TX_UUID "0000A002-0000-0000-0000-00A57E401D05"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change those ? If you are worried about backward compatibility since the protocol changes, don't worry, there are no users at the moment and it's undocumented, we're free to evolve it however we want.

Comment thread src/tap.cpp
}
close(sock);

qDebug() << "MTU reset to" << mtu;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a space after to necessary ? I never remember if this qDebug syntax does it automagically or not

Comment thread src/tap.cpp
const auto &value = it->second;

if (value.contains("Ethernet")) {
//QString name = value["Ethernet"].toMap()["Name"].toString();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop this ;)

Comment thread src/tap.cpp
qCritical() << "Failed to get IFFLAGS";
exit(1);
}
if (ifr.ifr_flags & IFF_UP) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's extract a few helpers to bring the interface up and to configure connman

Comment thread src/tap.cpp

void TAP::iffReset(int mtu) {
struct ifreq ifr = {};
auto sock = socket(PF_INET, SOCK_DGRAM, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this socket is just required to do ioctls, let's create it once as part of the constructor and keep the fd around.

Comment thread src/tap.cpp
// Poll the interface file descriptor
mNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this);
QObject::connect(mNotifier, &QSocketNotifier::activated, this, &TAP::fdActivated);
ifr.ifr_mtu = mtu - MY_ETH_TAP_HARD_FRAME_SIZE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reuse the mtuChanged() function here to avoid code duplication and chances that implementations drift over time :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants