Skip to content

Small ioctl and sendto bug fixes, and implement FIONBIO for Nginx#1179

Merged
stevenengler merged 2 commits intoshadow:devfrom
stevenengler:improve-socket-support
Mar 13, 2021
Merged

Small ioctl and sendto bug fixes, and implement FIONBIO for Nginx#1179
stevenengler merged 2 commits intoshadow:devfrom
stevenengler:improve-socket-support

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

@stevenengler stevenengler commented Mar 13, 2021

Fixes two socket bugs and implements FIONBIO for ioctl() to set a socket as non-blocking, which is required for Nginx.

Closes #344.

Nginx can be used with the following (still missing some syscalls and socket options, but it works):

$ shadow shadow-nginx.yaml

nginx.conf:

error_log stderr;

# shadow wants to run nginx in the foreground
daemon off;

# shadow doesn't support fork()
master_process off;
worker_processes 0;

# don't use the system pid file
pid nginx.pid;

events {
  # we're not using any workers, so this is the maximum number
  # of simultaneous connections we can support
  worker_connections 1024;
}

http {
  include             /etc/nginx/mime.types;
  default_type        application/octet-stream;

  # shadow does not support sendfile() nor TCP_NODELAY
  sendfile off;
  tcp_nodelay off;

  access_log off;

  server {
    listen 80;

    location / {
      root /var/www/html;
      index index.nginx-debian.html;
    }
  }
}

shadow-nginx.yaml:

options:
  stoptime: 10
topology:
- graphml: |
    <graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
      <key attr.name="packetloss" attr.type="double" for="edge" id="d4" />
      <key attr.name="latency" attr.type="double" for="edge" id="d3" />
      <key attr.name="bandwidthup" attr.type="int" for="node" id="d2" />
      <key attr.name="bandwidthdown" attr.type="int" for="node" id="d1" />
      <key attr.name="countrycode" attr.type="string" for="node" id="d0" />
      <graph edgedefault="undirected">
        <node id="poi-1">
          <data key="d0">US</data>
          <data key="d1">10240</data>
          <data key="d2">10240</data>
        </node>
        <edge source="poi-1" target="poi-1">
          <data key="d3">50.0</data>
          <data key="d4">0.0</data>
        </edge>
      </graph>
    </graphml>
plugins:
- id: nginx
  path: /usr/sbin/nginx
- id: curl
  path: /usr/bin/curl
hosts:
- id: server
  quantity: 1
  processes:
  - plugin: nginx
    starttime: 1
    arguments: -c /path/to/working-dir/nginx.conf -p /path/to/working-dir/shadow.data/hosts/server
- id: client
  quantity: 20
  processes:
  - plugin: curl
    starttime: 3
    arguments: server --verbose

@stevenengler stevenengler added Priority: Low Prioritized below most other issues Component: Main Composing the core Shadow executable labels Mar 13, 2021
@stevenengler stevenengler self-assigned this Mar 13, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 13, 2021

Codecov Report

Merging #1179 (55045f3) into dev (0291d41) will decrease coverage by 0.08%.
The diff coverage is 13.79%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1179      +/-   ##
==========================================
- Coverage   56.93%   56.85%   -0.09%     
==========================================
  Files         140      140              
  Lines       20181    20195      +14     
  Branches     4889     4891       +2     
==========================================
- Hits        11491    11481      -10     
- Misses       5663     5687      +24     
  Partials     3027     3027              
Flag Coverage Δ
tests 56.85% <13.79%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/host/descriptor/descriptor.c 73.22% <0.00%> (-1.78%) ⬇️
src/main/host/syscall/socket.c 79.88% <0.00%> (-0.15%) ⬇️
src/main/host/syscall/ioctl.c 40.78% <16.00%> (-8.45%) ⬇️
src/main/host/thread_ptrace.c 65.08% <0.00%> (-0.90%) ⬇️
src/main/routing/topology.c 42.70% <0.00%> (-0.24%) ⬇️
src/main/host/descriptor/file.c 31.27% <0.00%> (+0.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0291d41...55045f3. Read the comment docs.

@sporksmith
Copy link
Copy Markdown
Contributor

Woah, cool!

Copy link
Copy Markdown
Member

@robgjansen robgjansen left a comment

Choose a reason for hiding this comment

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

Looks great! I'm excited about Nginx support 👍

@stevenengler stevenengler merged commit 53597f0 into shadow:dev Mar 13, 2021
@stevenengler stevenengler deleted the improve-socket-support branch March 13, 2021 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Main Composing the core Shadow executable Priority: Low Prioritized below most other issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants