Commit Graph

51 Commits

Author SHA1 Message Date
Luminita Voicu eb8b8cb53d Add optional limit on request size
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
Luminita Voicu 7f3a14f16f forbid GET requests with body content
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
Luminita Voicu 83dcfdd22b reorder Http errors
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
Luminita Voicu a5fdf928eb response: minor comment fixes
Signed-off-by: Luminita Voicu <lumivo@amazon.com>
2021-07-09 11:32:22 +03:00
William Douglas 9b605a8b61 Enable creating a socket from an existing fd
Allow the creation of the http server's socket from an existing
fd. This is done to enable another process to initiate the creation of
a server by preparing the socket so it can immediately be used rather
than polling to connect to the path.

Note, the coverage file change due to what appears to be a rounding
error when calculating coverage.

Signed-off-by: William Douglas <william.douglas@intel.com>
2021-04-20 11:15:44 +03:00
YUAN LYU 49240ce1d5 Add unit tests to raise coverage score
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
YUAN LYU 9e6ab4b5ab Clean up after cherry-picking commits from firecracker
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
George Pisaltu e73f412536 micro-http: explicit HUP/ERR handling in server
The server in `micro_http` was not explicitly handling the `EPOLLHUP`,
`EPOLLRDHUP` and `EPOLLERR` epoll events. Added new checks that close
a connection that is signaled with these events.

Signed-off-by: George Pisaltu <gpl@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
berciuliviu ed44e2af6f Add error handling for fatal errors
This commit adds a mechanism that considers
some errors as 'fatal'. It alerts the user and then
terminates the Firecracker process.

Signed-off-by: berciuliviu <lberciu@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Gulshan Kumar 67fd749e03 Removed Unnecessary pub
Signed-off-by: Gulshan Kumar <kumargu@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Alexandru Cihodaru 683b85d07e Added support for Accept-Encoding
Signed-off-by: Alexandru Cihodaru <cihodar@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
cihodar 8a8d7bb5b1 Made InvalidHeader error more verbose.
Changed the way we handle TransferEncoding
and added new test cases.

Signed-off-by: cihodar <cihodar@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Damien Stanton eeae4ac11d Remove all extern crate...
In Rust 2018 edition, it is considered unidiomatic to use "extern crate"
sunthax. The proper way to do it is to replace extern crate with "use"
declarations.

- Also impl clippy suggestions for fn main removal in doctests
- Fix unneeded box allocations and clones

Signed-off-by: Damien Stanton <damien.stanton@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Damien Stanton a7f035b8c5 micro_http: switch to rust edition 2018
Signed-off-by: Damien Stanton <damien.stanton@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Alexandra Iordache 88de0ed16b micro-http: unsigned Content-Length...
...and a bunch of fixes for unchecked unsigned arithmetic
in connection.rs. Added more unit tests too that exercise
failure cases for over/underflows in mathematic operations.

Fixes #1977

Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
defunct 48b8f179c8 use epoll implementation from vmm-sys-util
Signed-off-by: defunct <defunct@defunct.io>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Ioana Chirca 17ead39d82 micro_http: check arithmetic operations
Signed-off-by: Ioana Chirca <chioana@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
moricho 9830b66a09 dumbo: remove dumbo's dependency on mmds
This moves dumbo::ns to mmds crate and
implements response retrieval callback passed to dumbo's tcp::handler

Signed-off-by: moricho <ikeda.morito@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
wt-l00 c5a3f9f543 Add more flexibility when parsing the headers
Any number of whitespace characters are accepted after ":"
when parsing HTTP headers.
Create a test function (Add test_parse_header_whitespace).
This test addresses parsing header and allow no space and
any amount of linear white space after ":". And modified
CHANGELOG.md.

Signed-off-by: Eisuke Matsushita <ei13suke@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
timvisee 3e888638e5 Implement clippy suggestions for Rust 1.43.1
Signed-off-by: timvisee <tim@visee.me>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Shion Yamashita 2e3f629054 micro_http: fix name of helper function in tests
Signed-off-by: Shion Yamashita <shioyama1118@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Shion Yamashita d7a7bd0fe2 Use TempFile when generating path to socket
Signed-off-by: Shion Yamashita <shioyama1118@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Iulian Barbu d37f9671af micro-http: added MethodNotAllow status code
When server returns `Method Not Allow` responses,
it can attach to the response a HTTP `Allow` header.
Added support for HTTP response `Allow` header as
well.

Signed-off-by: Iulian Barbu <iul@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Iulian Barbu 530b36bfd9 micro_http: add support for accept headers
Signed-off-by: Iulian Barbu <iul@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
iulianbarbu 4a25226f2a mmds: added support for custom ipv4 address
Added a new API for configuring MMDS. At the moment,
this configuration applies only for the MMDS IPv4 address.

Besides the new API, this commits comprises changes to the
NetBuilder implementation and usages.

Signed-off-by: iulianbarbu <iul@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Adrian Catangiu d288940391 micro_http: gracefully handle EINTR
EINTR errors should not break the HttpServer requests loop,
they are internally consumed and reported as no events rather
than requests errors.

Signed-off-by: Adrian Catangiu <acatan@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Popa 7eb11b44cb clean-up: get rid of misplaced cfg(test)
Signed-off-by: Popa <dpopa@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Laura Loghin 548d297be7 Completely remove epoll crate dependency
Move epoll.rs from polly to utils crate and use this file,
in micro_http, as an epoll wrapper instead of the epoll crate.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
keyangxie 7289d64e24 micro_http: update unit test
Add some test cases for uri test, to cover sub-domain uri
and `ip:port`.

Refactor `test_uri` and `test_find`. Leverage tupled vector
to init test inputs and expected values, and remove superfluous
lines. It will be more flexible to modify the test cases.

Signed-off-by: keyangxie <keyang.xie@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
karthik nedunchezhiyan 569230220f micro_http: some doc and code corrections
Signed-off-by: karthik nedunchezhiyan <karthik1705.n@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Bob Potter 4ee7142098 micro_http: adjust match on header fields
Use case-insensitive check since some http clients use lower case
headers.

Signed-off-by: Bob Potter <bobby.potter@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Changwei Ge 59ab64440a Add http status code 503
When we are not capable to provide a certain kind of service, but should be
after some delay. Http server is better to reply status code 503. It is more
suggestive per as to http spec.

```
The server is currently unable to handle the request due to a temporary
overload or scheduled maintenance, which will likely be alleviated after some delay.
```

Signed-off-by: Changwei Ge <chge@linux.alibaba.com>
2020-11-03 08:38:02 +02:00
Adrian Catangiu 40309b72ee add .gitignore file
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
2020-07-23 18:17:33 +03:00
Adrian Catangiu c33861a13b Handle ErrorKind::Interrupted when waiting for events
ErrorKind::Interrupted (libc::EINTR) errors should not break the
HttpServer requests loop, they are internally consumed and reported
as no events rather than requests errors.

Signed-off-by: Adrian Catangiu <acatan@amazon.com>
2020-07-23 18:17:33 +03:00
Liu Jiang c9ffb90aeb Handle ErrorKind::Interrupted when doing stream IO
When doing IO with the underlying stream object, we should handle
the special case of ErrorKind::Interrupted, otherwise the connection
will be closed incorrectly.

Quotation from Rust doc:
An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
read operation should be retried if there is nothing else to do.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-04-27 09:41:16 +03:00
Liu Jiang 0d87a94c8e Route request according to {method, path} tuple
Route request according to {method, path} tuple, so we could use only
one router for each http server.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang 8ca0839b58 Simplify the HttpRoute trait
Previously the HttpRoute has logic to clone the handler parameter,
which is an implementation detail of the API server. So simplify
the HttpRoute interfaces by removing the argument cloning logic.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang ac3bb940ab Import http routes from Cloud Hypervisor project
Import vmm/src/api/http.rs from Cloud Hyerpvisor project, commit
345c922cb9a88183e2da9d29230ecb945b0a6452 with following changes:
1) use generic type for handler argument.
2) remove server thread relative code.
3) add unit test cases.
4) refine for better code reuse.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang 31bc6268c7 Unregister fd from epoll_fd when closing a connection
When closing a http connection, the corresponding file descriptor
should be unregistered from the epoll fd.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang 3832d38d8c Reject negative content length in http header
It's almost an illegal input for a Content-Length header with negative
value, so reject it. Otherwise it may cause unexpected behavor when
parsing/receiving http requests.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang aefdd1be46 Refine documentation according to latest code
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang fbb4d5392a Refine code for rust edition 2018
Refine code to support rust edition 2018, no functional changes.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Andreea Florescu e89ed14707 added readme file
The readme is still WIP, but it was added so that we can have links
to the other documents in the repository.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-03-24 18:22:44 +02:00
Andreea Florescu 460020a10f added security policy document
This is adapted from firecracker's security policy document.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-03-24 18:22:44 +02:00
Andreea Florescu 0f741b9d2b added a basic changelog file
Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-03-24 18:22:44 +02:00
Andreea Florescu e8c0f8eaf0 added license
Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-03-24 18:22:44 +02:00
Andreea Florescu da92575813 added contribution guidelines
The contribution guidelines are adapted from the firecracker
repository.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-03-24 18:22:44 +02:00
Andreea Florescu ac31e5745f added github issue template
Adjusted the github issue template from Firecracker.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-03-24 18:22:44 +02:00
Andreea Florescu e712d6ae23 fix link issues on aarch64 musl
The linker was unable to find __addtf3, __multf3 and __subtf3.

Added target-feature=+crt-static and link-arg=-lgcc as a temporary
workaround. This seems to be the accepted fix in the Rust community:
rust-lang-nursery/compiler-builtins#201

A permanent fix is yet to be implemented in the Rust compiler.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-01-30 15:21:04 +02:00
Andreea Florescu fc538a8ba0 Added Buildkite CI
It's easier to test this with the rust-vmm-ci directly as it already
runs all the basic tests.

Signed-off-by: Andreea Florescu <fandree@amazon.com>
2020-01-30 15:21:04 +02:00