Skip to content

Lwip 2.0 #2767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 28, 2016
Merged

Lwip 2.0 #2767

merged 18 commits into from
Sep 28, 2016

Conversation

mikaleppanen
Copy link

Description

LWIP stack 2.0, LWIP stack adaptation code and mac driver updates.

Status

READY

Migrations

Updated freescale drivers to do or operation for multicast group filters:
hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K66F/drivers/fsl_enet.c
hal/targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/drivers/fsl_enet.c
(commit 92baa85b7b07dbcdfcb1422be03127d88ddded91)

Related PRs

List related PRs against other branches:
None

Todos

  • [X ] Tests
  • Documentation

Deploy notes

None

Steps to test or reproduce

None

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 21, 2016

cc @bulislaw @sg- @geky @kjbracey-arm

@mikaleppanen Can you share any tests run for this patch? how many targets were tested?

@bridadan
Copy link
Contributor

/morph test-nightly

@kjbracey
Copy link
Contributor

Testing so far has been limited to one particular end-to-end system test - we have got mbed-client-example to register with the device server using both IPv4 and IPv6 on K64F hardware, using UDP.

More directed targeted IP testing and testing on other platforms is required. The other platforms' drivers are compile-tested only.

@kjbracey
Copy link
Contributor

Note that the LWIP code that is being added is from the reference repository fork here:

https://github.com/ARMmbed/lwip

coming from the branch "mbed-os-prefixed", based on STABLE-2.0.0-rc2, with 2 bug fixes cherry-picked from master.

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 909

Build failed!

@bridadan
Copy link
Contributor

bridadan commented Sep 21, 2016

@kjbracey-arm and @mikaleppanen, you should have access to the CI report by following the bot's posted link. But here's a quick summary of one of the build failures for the RZ_A1H when built with ARM Compiler 5:

...
08:53:20 Compile: Ethernet.cpp
08:53:20 [Error] Ethernet.cpp@24,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@24,0:  #260-D: explicit type is missing ("int" assumed)
08:53:20 [Warning] Ethernet.cpp@26,0:  #940-D: missing return statement at end of non-void function "mbed::Ethernet"
08:53:20 [Error] Ethernet.cpp@28,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@32,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@36,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@40,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@44,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@48,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@52,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@56,0:  #276: name followed by "::" must be a class or namespace name
08:53:20 [Error] Ethernet.cpp@56,0:  #20: identifier "Mode" is undefined
08:53:20 [Error] Ethernet.cpp@61,0:  #20: identifier "AutoNegotiate" is undefined
08:53:20 [Error] Ethernet.cpp@62,0:  #20: identifier "HalfDuplex10" is undefined
08:53:20 [Error] Ethernet.cpp@63,0:  #20: identifier "FullDuplex10" is undefined
08:53:20 [Error] Ethernet.cpp@64,0:  #20: identifier "HalfDuplex100" is undefined
08:53:20 [Error] Ethernet.cpp@65,0:  #20: identifier "FullDuplex100" is undefined

EDIT: for further convenience, here's a direct link to the build matrix: http://10.118.12.43:8081/job/build_matrix/547/

@mikaleppanen
Copy link
Author

Corrected dual stack ipv6 preferred mode in 91c9f98

@bulislaw
Copy link
Member

CC: @andreaslarssonublox

@bridadan
Copy link
Contributor

@mikaleppanen Will the patch you pushed fix the build error I mentioned? Is this good to go for another test run?

@geky
Copy link
Contributor

geky commented Sep 21, 2016

This has a relatively large number of changes in a single pr, including conflicts with other prs that are currently under review (for example IPv6 support in SocketAddress #2652).

Could we limit the scope of this pr to only lwip and split other changes (especially changes to the network-socket API) into separate prs? This would allow us to properly review changes that impact the user API and other network-socket implementations.

@@ -20,11 +20,29 @@
#include "stddef.h"
#include <new>

static bool stackHasIPV4(NetworkStack *stack)
Copy link
Contributor

@geky geky Sep 21, 2016

Choose a reason for hiding this comment

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

Please stick with the existing naming convention: stack_has_ipv4
https://docs.mbed.com/docs/getting-started-mbed-os/en/latest/Full_Guide/Code_Style/

return 0;
}

if (stackHasIPV4(this)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe checking for literals should actually be handled in nsapi_dns_query (similarly to the POSIX gethostbyname)

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't make sense to me. Surely nsapi_dns_query should do what it name says - a DNS query. Having to add literal parsing to the DNS code too doesn't make sense - it has to be outside the DNS code anyway.

It's gethostbyname that has to handle literals before attemping a DNS query.

@@ -182,6 +182,8 @@ class Socket {
attach(mbed::callback(obj, method));
}

NetworkStack *stack() const { return _stack; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this function exposed publicly in the Socket class? The internal NetworkStack is intentionally hidden from the user API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason it was added is no longer valid, so it no longer needs to be added for this commit. (It was needed to implement the DNS work in the first draft.)

But I remain unconvinced of the merit of hiding NetworkStack.

*/
void set_ip_address(const char *addr);
bool set_ip_address(const char *addr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this is needed. If the set_ip_address call fails, the resulting SocketAddress will be null. Failure can be checked like so:

SocketAddress address;
address.set_ip_address("1.2.3.4");
if (!address) {
    // handle invalid address
}

We should avoid changing existing APIs unless there is evidence that the current API is insufficient or conflicts with the current coding guidelines.

Copy link
Contributor

@kjbracey kjbracey Sep 22, 2016

Choose a reason for hiding this comment

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

The SocketAddress will also be "null" after a valid parse of "0.0.0.0". Need to distinguish - otherwise we'd request a DNS lookup of "0.0.0.0". (Or "::").

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah interesting, that is a valid point.


// DNS options
#define DNS_BUFFER_SIZE 256
#define DNS_BUFFER_SIZE 512
Copy link
Contributor

@geky geky Sep 21, 2016

Choose a reason for hiding this comment

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

Just checking, was there a test that confirmed the original buffer size was too small?

Copy link
Contributor

Choose a reason for hiding this comment

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

The DNS spec says 512 bytes. We reduced it from 1024 to 512 during devlopment, but when we saw that someone else had been touching the DNS code (aargh), we saw you'd reduced it further to 256. Left it at 512 during conflict resolution.

Not seen any failures, but I'm not totally confident about using IPv6 DNS with half-sized buffers.

(We also made the original DNS reply parsing resilient to truncated results, but had to abandon it - wasn't straightforward to refit to the new code, which doesn't consider packet length at all).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha, wasn't aware of the DNS spec 👍

lwip/src/apps/*
lwip/src/netif/ppp/*
lwip/src/inlude/lwip/apps/*
lwip/src/inlude/posix/*
Copy link
Contributor

Choose a reason for hiding this comment

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

If the lwip codebase is being mirrored, shouldn't we just avoid adding these directories into mbed-os?

None of these seem to add a benefit except maybe documentation, which shouldn't present a compilation issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would mean writing special scripts and tools to cope with the variation, and more error-prone tracking of the upstream. This is attempting to work with the source control system rather than against it. (As much as we can given the limitations of mbed-os).

This way means it's just a single "git subtree add".

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you're right, removing the directories would be annoying.

It is possible to amend the subtree add commit to remove the directories, and this removal works cleanly with future subtree merges. But if the removed files are modified, it will introduce a merge conflict for every modification.

@@ -43,16 +43,21 @@ static bool ipv4_is_valid(const char *addr)
static bool ipv6_is_valid(const char *addr)
{
// Check each digit for [0-9a-fA-F:]
// Must also have at least 2 colons
int colons = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

+1, nice catch

addr_type = NETCONN_DNS_IPV4;
}
#endif
err_t err = netconn_gethostbyname_addrtype(host, &lwip_addr, addr_type);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like addr_type was declared conditionally based on LWIP_IPV4 && LWIP_IPV6. Has this been tested with other IP version configurations?

Copy link
Contributor

Choose a reason for hiding this comment

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

That actually does work, because the call is a macro that ignores its 3rd parameter unless both IPv4 and IPv6 are enabled. Should at least be commented, but probably better to not use the addrtype form unless in the if.

@mikaleppanen
Copy link
Author

@bridadan ethernet.h header collision is now corrected. Could you trigger tests again.

@bridadan
Copy link
Contributor

@mikaleppanen It sounds like there's still a discussion going on for this PR, maybe we should hold off until that has a chance to be resolved.

@sg-
Copy link
Contributor

sg- commented Sep 22, 2016

/morph test-nightly

@sg- sg- added needs: CI and removed needs: work labels Sep 22, 2016
@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 928

Test failed!

@geky
Copy link
Contributor

geky commented Sep 23, 2016

I've tried to merge the DNS changes into the pr over here: #2652

Let me know if I missed anything

@kjbracey
Copy link
Contributor

kjbracey commented Sep 23, 2016

Thanks - looks like we should be able to drop those bits from here. Have commented over there.

@mikaleppanen
Copy link
Author

TCP corrected in: 84194f04df688f403e19887d0357a29207fd16f6 could you retest

@bridadan
Copy link
Contributor

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 935

Test failed!

@mazimkhan
Copy link

retest uvisor

1 similar comment
@mazimkhan
Copy link

retest uvisor

@mikaleppanen
Copy link
Author

Updated to master and corrected inspection defect. Could you retest this.

@geky
Copy link
Contributor

geky commented Sep 27, 2016

/morph test-nightly

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 964

Test failed!

@mikaleppanen
Copy link
Author

Updated commit message 1d2130f

@kjbracey
Copy link
Contributor

When this does go in, please make sure it's a normal merge, not a squash or rebase, to preserve the lwIP subtree.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 28, 2016

@0xc0170 @geky @kjbracey-arm @bridadan @bogdanm any last comments?

LGTM, let's get this in soon, as we will need to rebase wifi feature branch.

@mikaleppanen
Copy link
Author

Corrected TCP keep alive interval 7d770366d17500ea50eea03fdf94e6a890a559b1

@kjbracey
Copy link
Contributor

On the TCP interval - it's not actually clear what is "correct".

NSAPI documentation doesn't specify the units of the interval, and it actually has always been milliseconds for lwIP - it's not a 1.4->2.0 change. So suggest that last commit moves to a separate pull request.

mbed client appears to have a default interval setting of 300 - it's assuming seconds. Not unreasonably, as that tends to be the unit used by most APIs (eg Linux sysctl, lwIP's own setsockopt). But it ends up getting a keepalive every half-second.

@mikaleppanen
Copy link
Author

Removed the TCP interval commit.

@bogdanm
Copy link
Contributor

bogdanm commented Sep 28, 2016

While I'm not very familiar with all the PR details, it looks good overall 👍

@geky
Copy link
Contributor

geky commented Sep 28, 2016

I'm still uncomfortable with the network-socket API changes in this pr. Given the size of the diff and the impact of the network-socket API, I don't believe these changes have had acceptable review. I'm not saying the changes won't be accepted, but we should have separate prs to track the network-socket API changes.

@sg- sg- merged commit 3d1531f into ARMmbed:master Sep 28, 2016
@kjbracey
Copy link
Contributor

Agree that it was an excessive lump, given that we're stuck with Github.

But the set of changes made sense as a single topic branch - they're all related to one aim - making IPv4+IPv6 work. Problem is Github PRs are a rubbish review tool. If this was Gerrit it would have been easy to review the individual patches.

Having a pull request review system but no proper patch review system is just sad. :(

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

Successfully merging this pull request may close these issues.

10 participants