Skip to content
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

portus api: deduplicate programs across flows #38

Merged
merged 1 commit into from
Sep 7, 2018
Merged

Conversation

deeptir18
Copy link
Member

This commit adds an init_programs function to the CCP API where users
must provide all datapath programs at the beginning, and whenever a flow
should use a particular program, they can use the new "set_program"
function.

I'll split up the commits later, sorry.

Copy link
Member

@akshayknarayan akshayknarayan left a comment

Choose a reason for hiding this comment

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

Overall looks good.
I have a couple code-style comments, and it seems like you haven't cleaned up your commented-out testing code yet.

@@ -347,6 +252,127 @@ impl<T: Ipc, A: GenericCongAvoidAlg> CongAlg<T> for GenericCongAvoid<T, A> {
A::name()
}

fn init_programs() -> Option<Vec<(Bin, Scope, String)>> {
// install all the datapath programs that can be used in the lifetime of this program
let mut vec = vec![];
Copy link
Member

Choose a reason for hiding this comment

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

let mut vec = vec![
  (String::from("(def.....)"), String::from("DatapathIntervalProg")),
  (String::from("(def.....)"), String::from("DatapathIntervalRTTProg")),
   ....,
];

Copy link
Member

Choose a reason for hiding this comment

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

This is cleaner than vec![] followed by multiple vec.push() calls.
Also, can we call the variable something other than vec? Maybe programs?

let (bin, sc) = portus::compile_program(prog.as_bytes(), None).unwrap();
ret_vec.push((bin, sc, prog_name.clone()));
}
Some(ret_vec)
Copy link
Member

Choose a reason for hiding this comment

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

Some(
vec.iter()
  .map(|prog, prog_name| {
    let (bin, sc) = portus::compile_program(prog.as_bytes(), None).unwrap();
    (bin, sc, prog_name.clone())
  })
  .collect::<Vec<(_,_,_)>>()

Copy link
Member

Choose a reason for hiding this comment

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

Instead of the for loop and the new vec

@@ -1,7 +1,7 @@
CC = gcc # C compiler
CFLAGS = -fPIC -Wall -Wextra -O2 -g # C flags
CFLAGS += -D__USRLIB__ # Only use this makefile for compiling user-space library
ifeq ($(DEBUG), 1)
ifeq ($(DEBUG), y)
Copy link
Member

Choose a reason for hiding this comment

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

different commit for this?

int err = 0;
if ((send_sock = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) {
printf("Could not setup sending socket\n");
exit(-1);
}

send_sockaddr.sun_family = AF_UNIX;
/*send_sockaddr.sun_family = AF_UNIX;
Copy link
Member

Choose a reason for hiding this comment

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

??

src/lib.rs Outdated
use ipc::Ipc;
use ipc::{BackendSender, BackendBuilder};
use serialize::Msg;
use std::sync::{Arc, atomic};
use std::thread;

/*pub struct ScopeMap {
Copy link
Member

Choose a reason for hiding this comment

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

What is ScopeMap?

self.sender.send_msg(&buf[..])?;
Ok(sc.clone())
},
_ => Err(Error(
Copy link
Member

Choose a reason for hiding this comment

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

indentation here

Copy link
Member Author

Choose a reason for hiding this comment

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

wait what should this look like

Copy link
Member

Choose a reason for hiding this comment

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

oh I was just thinking:

_ => Err(Error(
    format!("Map....", program_name),
)),

pub struct Msg {
pub sid: u32,
pub program_uid: u32,
pub num_fields: u32, // question: does this get turned into a u32?
Copy link
Member

Choose a reason for hiding this comment

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

during serialization

@akshayknarayan
Copy link
Member

Also @deeptir18 since this is a breaking API change, please bump the portus version in Cargo.toml to 0.3.0

Copy link
Member

@fcangialosi fcangialosi left a comment

Choose a reason for hiding this comment

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

no comments aside from what Akshay already mentioned

@deeptir18 deeptir18 force-pushed the deduplicate branch 2 times, most recently from 965d228 to 4735ee8 Compare September 7, 2018 01:20
Copy link
Member

@akshayknarayan akshayknarayan left a comment

Choose a reason for hiding this comment

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

Version number should be 0.3.0 :)

Cargo.toml Outdated
@@ -1,7 +1,7 @@
[package]
name = "portus"
version = "0.2.3"
authors = ["Akshay Narayan <akshayn@csail.mit.edu>", "Frank Cangialosi <frankc@csail.mit.edu", "Deepti Raghavan <deeptir@stanford.edu"]
version = "0.2.4"
Copy link
Member

Choose a reason for hiding this comment

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

0.3.0: because it's a breaking change, we want to make sure downstream crates which write portus = "0.2" as their SemVer dependency don't pull in this change and break.

struct sockaddr_un send_sockaddr;
int path_len = 0;
//struct sockaddr_un send_sockaddr;
//int path_len = 0;
Copy link
Member

Choose a reason for hiding this comment

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

why is this commented?

@@ -277,11 +274,13 @@ int main(__attribute__((unused))int argc, __attribute__((unused))char **argv) {
int recv_sock = setup_listening_thread();

// initialize a fake connection; sends create messages
// sleep to make sure portus has started
sleep(2);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is necessary, but let's not worry about it now, since my PR #37 will fix it anyway.

self.sender.send_msg(&buf[..])?;
Ok(sc.clone())
},
_ => Err(Error(
Copy link
Member

Choose a reason for hiding this comment

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

oh I was just thinking:

_ => Err(Error(
    format!("Map....", program_name),
)),


"), String::from("SSUpdateProg"))];
Some(
programs.iter()
Copy link
Member

Choose a reason for hiding this comment

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

indentation here

This commit modifies the CCP API to expect users to install all programs
in the new init_programs function, when portus starts running. To make a
flow use a particular program, there is a new set_program function; when
installing, users also specify a name for each program. In the datapath,
now, programs need not be duplicated across flows. This also bumps the
libccp submodule version to match the corresponding changes in libccp.
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.

None yet

3 participants